6054c8238a6ead764130056d8c69d30e.js 307 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904
  1. "no use strict";
  2. !(function(window) {
  3. if (typeof window.window != "undefined" && window.document)
  4. return;
  5. if (window.require && window.define)
  6. return;
  7. if (!window.console) {
  8. window.console = function() {
  9. var msgs = Array.prototype.slice.call(arguments, 0);
  10. postMessage({type: "log", data: msgs});
  11. };
  12. window.console.error =
  13. window.console.warn =
  14. window.console.log =
  15. window.console.trace = window.console;
  16. }
  17. window.window = window;
  18. window.ace = window;
  19. window.onerror = function(message, file, line, col, err) {
  20. postMessage({type: "error", data: {
  21. message: message,
  22. data: err && err.data,
  23. file: file,
  24. line: line,
  25. col: col,
  26. stack: err && err.stack
  27. }});
  28. };
  29. window.normalizeModule = function(parentId, moduleName) {
  30. // normalize plugin requires
  31. if (moduleName.indexOf("!") !== -1) {
  32. var chunks = moduleName.split("!");
  33. return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
  34. }
  35. // normalize relative requires
  36. if (moduleName.charAt(0) == ".") {
  37. var base = parentId.split("/").slice(0, -1).join("/");
  38. moduleName = (base ? base + "/" : "") + moduleName;
  39. while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
  40. var previous = moduleName;
  41. moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  42. }
  43. }
  44. return moduleName;
  45. };
  46. window.require = function require(parentId, id) {
  47. if (!id) {
  48. id = parentId;
  49. parentId = null;
  50. }
  51. if (!id.charAt)
  52. throw new Error("worker.js require() accepts only (parentId, id) as arguments");
  53. id = window.normalizeModule(parentId, id);
  54. var module = window.require.modules[id];
  55. if (module) {
  56. if (!module.initialized) {
  57. module.initialized = true;
  58. module.exports = module.factory().exports;
  59. }
  60. return module.exports;
  61. }
  62. if (!window.require.tlns)
  63. return console.log("unable to load " + id);
  64. var path = resolveModuleId(id, window.require.tlns);
  65. if (path.slice(-3) != ".js") path += ".js";
  66. window.require.id = id;
  67. window.require.modules[id] = {}; // prevent infinite loop on broken modules
  68. importScripts(path);
  69. return window.require(parentId, id);
  70. };
  71. function resolveModuleId(id, paths) {
  72. var testPath = id, tail = "";
  73. while (testPath) {
  74. var alias = paths[testPath];
  75. if (typeof alias == "string") {
  76. return alias + tail;
  77. } else if (alias) {
  78. return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
  79. } else if (alias === false) {
  80. return "";
  81. }
  82. var i = testPath.lastIndexOf("/");
  83. if (i === -1) break;
  84. tail = testPath.substr(i) + tail;
  85. testPath = testPath.slice(0, i);
  86. }
  87. return id;
  88. }
  89. window.require.modules = {};
  90. window.require.tlns = {};
  91. window.define = function(id, deps, factory) {
  92. if (arguments.length == 2) {
  93. factory = deps;
  94. if (typeof id != "string") {
  95. deps = id;
  96. id = window.require.id;
  97. }
  98. } else if (arguments.length == 1) {
  99. factory = id;
  100. deps = [];
  101. id = window.require.id;
  102. }
  103. if (typeof factory != "function") {
  104. window.require.modules[id] = {
  105. exports: factory,
  106. initialized: true
  107. };
  108. return;
  109. }
  110. if (!deps.length)
  111. // If there is no dependencies, we inject "require", "exports" and
  112. // "module" as dependencies, to provide CommonJS compatibility.
  113. deps = ["require", "exports", "module"];
  114. var req = function(childId) {
  115. return window.require(id, childId);
  116. };
  117. window.require.modules[id] = {
  118. exports: {},
  119. factory: function() {
  120. var module = this;
  121. var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
  122. switch (dep) {
  123. // Because "require", "exports" and "module" aren't actual
  124. // dependencies, we must handle them seperately.
  125. case "require": return req;
  126. case "exports": return module.exports;
  127. case "module": return module;
  128. // But for all other dependencies, we can just go ahead and
  129. // require them.
  130. default: return req(dep);
  131. }
  132. }));
  133. if (returnExports)
  134. module.exports = returnExports;
  135. return module;
  136. }
  137. };
  138. };
  139. window.define.amd = {};
  140. window.require.tlns = {};
  141. window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
  142. for (var i in topLevelNamespaces)
  143. this.require.tlns[i] = topLevelNamespaces[i];
  144. };
  145. window.initSender = function initSender() {
  146. var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
  147. var oop = window.require("ace/lib/oop");
  148. var Sender = function() {};
  149. (function() {
  150. oop.implement(this, EventEmitter);
  151. this.callback = function(data, callbackId) {
  152. postMessage({
  153. type: "call",
  154. id: callbackId,
  155. data: data
  156. });
  157. };
  158. this.emit = function(name, data) {
  159. postMessage({
  160. type: "event",
  161. name: name,
  162. data: data
  163. });
  164. };
  165. }).call(Sender.prototype);
  166. return new Sender();
  167. };
  168. var main = window.main = null;
  169. var sender = window.sender = null;
  170. window.onmessage = function(e) {
  171. var msg = e.data;
  172. if (msg.event && sender) {
  173. sender._signal(msg.event, msg.data);
  174. }
  175. else if (msg.command) {
  176. if (main[msg.command])
  177. main[msg.command].apply(main, msg.args);
  178. else if (window[msg.command])
  179. window[msg.command].apply(window, msg.args);
  180. else
  181. throw new Error("Unknown command:" + msg.command);
  182. }
  183. else if (msg.init) {
  184. window.initBaseUrls(msg.tlns);
  185. sender = window.sender = window.initSender();
  186. var clazz = this.require(msg.module)[msg.classname];
  187. main = window.main = new clazz(sender);
  188. }
  189. };
  190. })(this);
  191. ace.define("ace/lib/oop",[], function(require, exports, module){"use strict";
  192. exports.inherits = function (ctor, superCtor) {
  193. ctor.super_ = superCtor;
  194. ctor.prototype = Object.create(superCtor.prototype, {
  195. constructor: {
  196. value: ctor,
  197. enumerable: false,
  198. writable: true,
  199. configurable: true
  200. }
  201. });
  202. };
  203. exports.mixin = function (obj, mixin) {
  204. for (var key in mixin) {
  205. obj[key] = mixin[key];
  206. }
  207. return obj;
  208. };
  209. exports.implement = function (proto, mixin) {
  210. exports.mixin(proto, mixin);
  211. };
  212. });
  213. ace.define("ace/lib/lang",[], function(require, exports, module){"use strict";
  214. exports.last = function (a) {
  215. return a[a.length - 1];
  216. };
  217. exports.stringReverse = function (string) {
  218. return string.split("").reverse().join("");
  219. };
  220. exports.stringRepeat = function (string, count) {
  221. var result = '';
  222. while (count > 0) {
  223. if (count & 1)
  224. result += string;
  225. if (count >>= 1)
  226. string += string;
  227. }
  228. return result;
  229. };
  230. var trimBeginRegexp = /^\s\s*/;
  231. var trimEndRegexp = /\s\s*$/;
  232. exports.stringTrimLeft = function (string) {
  233. return string.replace(trimBeginRegexp, '');
  234. };
  235. exports.stringTrimRight = function (string) {
  236. return string.replace(trimEndRegexp, '');
  237. };
  238. exports.copyObject = function (obj) {
  239. var copy = {};
  240. for (var key in obj) {
  241. copy[key] = obj[key];
  242. }
  243. return copy;
  244. };
  245. exports.copyArray = function (array) {
  246. var copy = [];
  247. for (var i = 0, l = array.length; i < l; i++) {
  248. if (array[i] && typeof array[i] == "object")
  249. copy[i] = this.copyObject(array[i]);
  250. else
  251. copy[i] = array[i];
  252. }
  253. return copy;
  254. };
  255. exports.deepCopy = function deepCopy(obj) {
  256. if (typeof obj !== "object" || !obj)
  257. return obj;
  258. var copy;
  259. if (Array.isArray(obj)) {
  260. copy = [];
  261. for (var key = 0; key < obj.length; key++) {
  262. copy[key] = deepCopy(obj[key]);
  263. }
  264. return copy;
  265. }
  266. if (Object.prototype.toString.call(obj) !== "[object Object]")
  267. return obj;
  268. copy = {};
  269. for (var key in obj)
  270. copy[key] = deepCopy(obj[key]);
  271. return copy;
  272. };
  273. exports.arrayToMap = function (arr) {
  274. var map = {};
  275. for (var i = 0; i < arr.length; i++) {
  276. map[arr[i]] = 1;
  277. }
  278. return map;
  279. };
  280. exports.createMap = function (props) {
  281. var map = Object.create(null);
  282. for (var i in props) {
  283. map[i] = props[i];
  284. }
  285. return map;
  286. };
  287. exports.arrayRemove = function (array, value) {
  288. for (var i = 0; i <= array.length; i++) {
  289. if (value === array[i]) {
  290. array.splice(i, 1);
  291. }
  292. }
  293. };
  294. exports.escapeRegExp = function (str) {
  295. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  296. };
  297. exports.escapeHTML = function (str) {
  298. return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  299. };
  300. exports.getMatchOffsets = function (string, regExp) {
  301. var matches = [];
  302. string.replace(regExp, function (str) {
  303. matches.push({
  304. offset: arguments[arguments.length - 2],
  305. length: str.length
  306. });
  307. });
  308. return matches;
  309. };
  310. exports.deferredCall = function (fcn) {
  311. var timer = null;
  312. var callback = function () {
  313. timer = null;
  314. fcn();
  315. };
  316. var deferred = function (timeout) {
  317. deferred.cancel();
  318. timer = setTimeout(callback, timeout || 0);
  319. return deferred;
  320. };
  321. deferred.schedule = deferred;
  322. deferred.call = function () {
  323. this.cancel();
  324. fcn();
  325. return deferred;
  326. };
  327. deferred.cancel = function () {
  328. clearTimeout(timer);
  329. timer = null;
  330. return deferred;
  331. };
  332. deferred.isPending = function () {
  333. return timer;
  334. };
  335. return deferred;
  336. };
  337. exports.delayedCall = function (fcn, defaultTimeout) {
  338. var timer = null;
  339. var callback = function () {
  340. timer = null;
  341. fcn();
  342. };
  343. var _self = function (timeout) {
  344. if (timer == null)
  345. timer = setTimeout(callback, timeout || defaultTimeout);
  346. };
  347. _self.delay = function (timeout) {
  348. timer && clearTimeout(timer);
  349. timer = setTimeout(callback, timeout || defaultTimeout);
  350. };
  351. _self.schedule = _self;
  352. _self.call = function () {
  353. this.cancel();
  354. fcn();
  355. };
  356. _self.cancel = function () {
  357. timer && clearTimeout(timer);
  358. timer = null;
  359. };
  360. _self.isPending = function () {
  361. return timer;
  362. };
  363. return _self;
  364. };
  365. });
  366. ace.define("ace/apply_delta",[], function(require, exports, module){"use strict";
  367. function throwDeltaError(delta, errorText) {
  368. console.log("Invalid Delta:", delta);
  369. throw "Invalid Delta: " + errorText;
  370. }
  371. function positionInDocument(docLines, position) {
  372. return position.row >= 0 && position.row < docLines.length &&
  373. position.column >= 0 && position.column <= docLines[position.row].length;
  374. }
  375. function validateDelta(docLines, delta) {
  376. if (delta.action != "insert" && delta.action != "remove")
  377. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  378. if (!(delta.lines instanceof Array))
  379. throwDeltaError(delta, "delta.lines must be an Array");
  380. if (!delta.start || !delta.end)
  381. throwDeltaError(delta, "delta.start/end must be an present");
  382. var start = delta.start;
  383. if (!positionInDocument(docLines, delta.start))
  384. throwDeltaError(delta, "delta.start must be contained in document");
  385. var end = delta.end;
  386. if (delta.action == "remove" && !positionInDocument(docLines, end))
  387. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  388. var numRangeRows = end.row - start.row;
  389. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  390. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  391. throwDeltaError(delta, "delta.range must match delta lines");
  392. }
  393. exports.applyDelta = function (docLines, delta, doNotValidate) {
  394. var row = delta.start.row;
  395. var startColumn = delta.start.column;
  396. var line = docLines[row] || "";
  397. switch (delta.action) {
  398. case "insert":
  399. var lines = delta.lines;
  400. if (lines.length === 1) {
  401. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  402. }
  403. else {
  404. var args = [row, 1].concat(delta.lines);
  405. docLines.splice.apply(docLines, args);
  406. docLines[row] = line.substring(0, startColumn) + docLines[row];
  407. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  408. }
  409. break;
  410. case "remove":
  411. var endColumn = delta.end.column;
  412. var endRow = delta.end.row;
  413. if (row === endRow) {
  414. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  415. }
  416. else {
  417. docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn));
  418. }
  419. break;
  420. }
  421. };
  422. });
  423. ace.define("ace/lib/event_emitter",[], function(require, exports, module){"use strict";
  424. var EventEmitter = {};
  425. var stopPropagation = function () { this.propagationStopped = true; };
  426. var preventDefault = function () { this.defaultPrevented = true; };
  427. EventEmitter._emit =
  428. EventEmitter._dispatchEvent = function (eventName, e) {
  429. this._eventRegistry || (this._eventRegistry = {});
  430. this._defaultHandlers || (this._defaultHandlers = {});
  431. var listeners = this._eventRegistry[eventName] || [];
  432. var defaultHandler = this._defaultHandlers[eventName];
  433. if (!listeners.length && !defaultHandler)
  434. return;
  435. if (typeof e != "object" || !e)
  436. e = {};
  437. if (!e.type)
  438. e.type = eventName;
  439. if (!e.stopPropagation)
  440. e.stopPropagation = stopPropagation;
  441. if (!e.preventDefault)
  442. e.preventDefault = preventDefault;
  443. listeners = listeners.slice();
  444. for (var i = 0; i < listeners.length; i++) {
  445. listeners[i](e, this);
  446. if (e.propagationStopped)
  447. break;
  448. }
  449. if (defaultHandler && !e.defaultPrevented)
  450. return defaultHandler(e, this);
  451. };
  452. EventEmitter._signal = function (eventName, e) {
  453. var listeners = (this._eventRegistry || {})[eventName];
  454. if (!listeners)
  455. return;
  456. listeners = listeners.slice();
  457. for (var i = 0; i < listeners.length; i++)
  458. listeners[i](e, this);
  459. };
  460. EventEmitter.once = function (eventName, callback) {
  461. var _self = this;
  462. this.on(eventName, function newCallback() {
  463. _self.off(eventName, newCallback);
  464. callback.apply(null, arguments);
  465. });
  466. if (!callback) {
  467. return new Promise(function (resolve) {
  468. callback = resolve;
  469. });
  470. }
  471. };
  472. EventEmitter.setDefaultHandler = function (eventName, callback) {
  473. var handlers = this._defaultHandlers;
  474. if (!handlers)
  475. handlers = this._defaultHandlers = { _disabled_: {} };
  476. if (handlers[eventName]) {
  477. var old = handlers[eventName];
  478. var disabled = handlers._disabled_[eventName];
  479. if (!disabled)
  480. handlers._disabled_[eventName] = disabled = [];
  481. disabled.push(old);
  482. var i = disabled.indexOf(callback);
  483. if (i != -1)
  484. disabled.splice(i, 1);
  485. }
  486. handlers[eventName] = callback;
  487. };
  488. EventEmitter.removeDefaultHandler = function (eventName, callback) {
  489. var handlers = this._defaultHandlers;
  490. if (!handlers)
  491. return;
  492. var disabled = handlers._disabled_[eventName];
  493. if (handlers[eventName] == callback) {
  494. if (disabled)
  495. this.setDefaultHandler(eventName, disabled.pop());
  496. }
  497. else if (disabled) {
  498. var i = disabled.indexOf(callback);
  499. if (i != -1)
  500. disabled.splice(i, 1);
  501. }
  502. };
  503. EventEmitter.on =
  504. EventEmitter.addEventListener = function (eventName, callback, capturing) {
  505. this._eventRegistry = this._eventRegistry || {};
  506. var listeners = this._eventRegistry[eventName];
  507. if (!listeners)
  508. listeners = this._eventRegistry[eventName] = [];
  509. if (listeners.indexOf(callback) == -1)
  510. listeners[capturing ? "unshift" : "push"](callback);
  511. return callback;
  512. };
  513. EventEmitter.off =
  514. EventEmitter.removeListener =
  515. EventEmitter.removeEventListener = function (eventName, callback) {
  516. this._eventRegistry = this._eventRegistry || {};
  517. var listeners = this._eventRegistry[eventName];
  518. if (!listeners)
  519. return;
  520. var index = listeners.indexOf(callback);
  521. if (index !== -1)
  522. listeners.splice(index, 1);
  523. };
  524. EventEmitter.removeAllListeners = function (eventName) {
  525. if (!eventName)
  526. this._eventRegistry = this._defaultHandlers = undefined;
  527. if (this._eventRegistry)
  528. this._eventRegistry[eventName] = undefined;
  529. if (this._defaultHandlers)
  530. this._defaultHandlers[eventName] = undefined;
  531. };
  532. exports.EventEmitter = EventEmitter;
  533. });
  534. ace.define("ace/range",[], function(require, exports, module){"use strict";
  535. var comparePoints = function (p1, p2) {
  536. return p1.row - p2.row || p1.column - p2.column;
  537. };
  538. var Range = function (startRow, startColumn, endRow, endColumn) {
  539. this.start = {
  540. row: startRow,
  541. column: startColumn
  542. };
  543. this.end = {
  544. row: endRow,
  545. column: endColumn
  546. };
  547. };
  548. (function () {
  549. this.isEqual = function (range) {
  550. return this.start.row === range.start.row &&
  551. this.end.row === range.end.row &&
  552. this.start.column === range.start.column &&
  553. this.end.column === range.end.column;
  554. };
  555. this.toString = function () {
  556. return ("Range: [" + this.start.row + "/" + this.start.column +
  557. "] -> [" + this.end.row + "/" + this.end.column + "]");
  558. };
  559. this.contains = function (row, column) {
  560. return this.compare(row, column) == 0;
  561. };
  562. this.compareRange = function (range) {
  563. var cmp, end = range.end, start = range.start;
  564. cmp = this.compare(end.row, end.column);
  565. if (cmp == 1) {
  566. cmp = this.compare(start.row, start.column);
  567. if (cmp == 1) {
  568. return 2;
  569. }
  570. else if (cmp == 0) {
  571. return 1;
  572. }
  573. else {
  574. return 0;
  575. }
  576. }
  577. else if (cmp == -1) {
  578. return -2;
  579. }
  580. else {
  581. cmp = this.compare(start.row, start.column);
  582. if (cmp == -1) {
  583. return -1;
  584. }
  585. else if (cmp == 1) {
  586. return 42;
  587. }
  588. else {
  589. return 0;
  590. }
  591. }
  592. };
  593. this.comparePoint = function (p) {
  594. return this.compare(p.row, p.column);
  595. };
  596. this.containsRange = function (range) {
  597. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  598. };
  599. this.intersects = function (range) {
  600. var cmp = this.compareRange(range);
  601. return (cmp == -1 || cmp == 0 || cmp == 1);
  602. };
  603. this.isEnd = function (row, column) {
  604. return this.end.row == row && this.end.column == column;
  605. };
  606. this.isStart = function (row, column) {
  607. return this.start.row == row && this.start.column == column;
  608. };
  609. this.setStart = function (row, column) {
  610. if (typeof row == "object") {
  611. this.start.column = row.column;
  612. this.start.row = row.row;
  613. }
  614. else {
  615. this.start.row = row;
  616. this.start.column = column;
  617. }
  618. };
  619. this.setEnd = function (row, column) {
  620. if (typeof row == "object") {
  621. this.end.column = row.column;
  622. this.end.row = row.row;
  623. }
  624. else {
  625. this.end.row = row;
  626. this.end.column = column;
  627. }
  628. };
  629. this.inside = function (row, column) {
  630. if (this.compare(row, column) == 0) {
  631. if (this.isEnd(row, column) || this.isStart(row, column)) {
  632. return false;
  633. }
  634. else {
  635. return true;
  636. }
  637. }
  638. return false;
  639. };
  640. this.insideStart = function (row, column) {
  641. if (this.compare(row, column) == 0) {
  642. if (this.isEnd(row, column)) {
  643. return false;
  644. }
  645. else {
  646. return true;
  647. }
  648. }
  649. return false;
  650. };
  651. this.insideEnd = function (row, column) {
  652. if (this.compare(row, column) == 0) {
  653. if (this.isStart(row, column)) {
  654. return false;
  655. }
  656. else {
  657. return true;
  658. }
  659. }
  660. return false;
  661. };
  662. this.compare = function (row, column) {
  663. if (!this.isMultiLine()) {
  664. if (row === this.start.row) {
  665. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  666. }
  667. }
  668. if (row < this.start.row)
  669. return -1;
  670. if (row > this.end.row)
  671. return 1;
  672. if (this.start.row === row)
  673. return column >= this.start.column ? 0 : -1;
  674. if (this.end.row === row)
  675. return column <= this.end.column ? 0 : 1;
  676. return 0;
  677. };
  678. this.compareStart = function (row, column) {
  679. if (this.start.row == row && this.start.column == column) {
  680. return -1;
  681. }
  682. else {
  683. return this.compare(row, column);
  684. }
  685. };
  686. this.compareEnd = function (row, column) {
  687. if (this.end.row == row && this.end.column == column) {
  688. return 1;
  689. }
  690. else {
  691. return this.compare(row, column);
  692. }
  693. };
  694. this.compareInside = function (row, column) {
  695. if (this.end.row == row && this.end.column == column) {
  696. return 1;
  697. }
  698. else if (this.start.row == row && this.start.column == column) {
  699. return -1;
  700. }
  701. else {
  702. return this.compare(row, column);
  703. }
  704. };
  705. this.clipRows = function (firstRow, lastRow) {
  706. if (this.end.row > lastRow)
  707. var end = { row: lastRow + 1, column: 0 };
  708. else if (this.end.row < firstRow)
  709. var end = { row: firstRow, column: 0 };
  710. if (this.start.row > lastRow)
  711. var start = { row: lastRow + 1, column: 0 };
  712. else if (this.start.row < firstRow)
  713. var start = { row: firstRow, column: 0 };
  714. return Range.fromPoints(start || this.start, end || this.end);
  715. };
  716. this.extend = function (row, column) {
  717. var cmp = this.compare(row, column);
  718. if (cmp == 0)
  719. return this;
  720. else if (cmp == -1)
  721. var start = { row: row, column: column };
  722. else
  723. var end = { row: row, column: column };
  724. return Range.fromPoints(start || this.start, end || this.end);
  725. };
  726. this.isEmpty = function () {
  727. return (this.start.row === this.end.row && this.start.column === this.end.column);
  728. };
  729. this.isMultiLine = function () {
  730. return (this.start.row !== this.end.row);
  731. };
  732. this.clone = function () {
  733. return Range.fromPoints(this.start, this.end);
  734. };
  735. this.collapseRows = function () {
  736. if (this.end.column == 0)
  737. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0);
  738. else
  739. return new Range(this.start.row, 0, this.end.row, 0);
  740. };
  741. this.toScreenRange = function (session) {
  742. var screenPosStart = session.documentToScreenPosition(this.start);
  743. var screenPosEnd = session.documentToScreenPosition(this.end);
  744. return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column);
  745. };
  746. this.moveBy = function (row, column) {
  747. this.start.row += row;
  748. this.start.column += column;
  749. this.end.row += row;
  750. this.end.column += column;
  751. };
  752. }).call(Range.prototype);
  753. Range.fromPoints = function (start, end) {
  754. return new Range(start.row, start.column, end.row, end.column);
  755. };
  756. Range.comparePoints = comparePoints;
  757. Range.comparePoints = function (p1, p2) {
  758. return p1.row - p2.row || p1.column - p2.column;
  759. };
  760. exports.Range = Range;
  761. });
  762. ace.define("ace/anchor",[], function(require, exports, module){"use strict";
  763. var oop = require("./lib/oop");
  764. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  765. var Anchor = exports.Anchor = function (doc, row, column) {
  766. this.$onChange = this.onChange.bind(this);
  767. this.attach(doc);
  768. if (typeof column == "undefined")
  769. this.setPosition(row.row, row.column);
  770. else
  771. this.setPosition(row, column);
  772. };
  773. (function () {
  774. oop.implement(this, EventEmitter);
  775. this.getPosition = function () {
  776. return this.$clipPositionToDocument(this.row, this.column);
  777. };
  778. this.getDocument = function () {
  779. return this.document;
  780. };
  781. this.$insertRight = false;
  782. this.onChange = function (delta) {
  783. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  784. return;
  785. if (delta.start.row > this.row)
  786. return;
  787. var point = $getTransformedPoint(delta, { row: this.row, column: this.column }, this.$insertRight);
  788. this.setPosition(point.row, point.column, true);
  789. };
  790. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  791. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  792. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  793. }
  794. function $getTransformedPoint(delta, point, moveIfEqual) {
  795. var deltaIsInsert = delta.action == "insert";
  796. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  797. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  798. var deltaStart = delta.start;
  799. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  800. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  801. return {
  802. row: point.row,
  803. column: point.column
  804. };
  805. }
  806. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  807. return {
  808. row: point.row + deltaRowShift,
  809. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  810. };
  811. }
  812. return {
  813. row: deltaStart.row,
  814. column: deltaStart.column
  815. };
  816. }
  817. this.setPosition = function (row, column, noClip) {
  818. var pos;
  819. if (noClip) {
  820. pos = {
  821. row: row,
  822. column: column
  823. };
  824. }
  825. else {
  826. pos = this.$clipPositionToDocument(row, column);
  827. }
  828. if (this.row == pos.row && this.column == pos.column)
  829. return;
  830. var old = {
  831. row: this.row,
  832. column: this.column
  833. };
  834. this.row = pos.row;
  835. this.column = pos.column;
  836. this._signal("change", {
  837. old: old,
  838. value: pos
  839. });
  840. };
  841. this.detach = function () {
  842. this.document.off("change", this.$onChange);
  843. };
  844. this.attach = function (doc) {
  845. this.document = doc || this.document;
  846. this.document.on("change", this.$onChange);
  847. };
  848. this.$clipPositionToDocument = function (row, column) {
  849. var pos = {};
  850. if (row >= this.document.getLength()) {
  851. pos.row = Math.max(0, this.document.getLength() - 1);
  852. pos.column = this.document.getLine(pos.row).length;
  853. }
  854. else if (row < 0) {
  855. pos.row = 0;
  856. pos.column = 0;
  857. }
  858. else {
  859. pos.row = row;
  860. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  861. }
  862. if (column < 0)
  863. pos.column = 0;
  864. return pos;
  865. };
  866. }).call(Anchor.prototype);
  867. });
  868. ace.define("ace/document",[], function(require, exports, module){"use strict";
  869. var oop = require("./lib/oop");
  870. var applyDelta = require("./apply_delta").applyDelta;
  871. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  872. var Range = require("./range").Range;
  873. var Anchor = require("./anchor").Anchor;
  874. var Document = function (textOrLines) {
  875. this.$lines = [""];
  876. if (textOrLines.length === 0) {
  877. this.$lines = [""];
  878. }
  879. else if (Array.isArray(textOrLines)) {
  880. this.insertMergedLines({ row: 0, column: 0 }, textOrLines);
  881. }
  882. else {
  883. this.insert({ row: 0, column: 0 }, textOrLines);
  884. }
  885. };
  886. (function () {
  887. oop.implement(this, EventEmitter);
  888. this.setValue = function (text) {
  889. var len = this.getLength() - 1;
  890. this.remove(new Range(0, 0, len, this.getLine(len).length));
  891. this.insert({ row: 0, column: 0 }, text);
  892. };
  893. this.getValue = function () {
  894. return this.getAllLines().join(this.getNewLineCharacter());
  895. };
  896. this.createAnchor = function (row, column) {
  897. return new Anchor(this, row, column);
  898. };
  899. if ("aaa".split(/a/).length === 0) {
  900. this.$split = function (text) {
  901. return text.replace(/\r\n|\r/g, "\n").split("\n");
  902. };
  903. }
  904. else {
  905. this.$split = function (text) {
  906. return text.split(/\r\n|\r|\n/);
  907. };
  908. }
  909. this.$detectNewLine = function (text) {
  910. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  911. this.$autoNewLine = match ? match[1] : "\n";
  912. this._signal("changeNewLineMode");
  913. };
  914. this.getNewLineCharacter = function () {
  915. switch (this.$newLineMode) {
  916. case "windows":
  917. return "\r\n";
  918. case "unix":
  919. return "\n";
  920. default:
  921. return this.$autoNewLine || "\n";
  922. }
  923. };
  924. this.$autoNewLine = "";
  925. this.$newLineMode = "auto";
  926. this.setNewLineMode = function (newLineMode) {
  927. if (this.$newLineMode === newLineMode)
  928. return;
  929. this.$newLineMode = newLineMode;
  930. this._signal("changeNewLineMode");
  931. };
  932. this.getNewLineMode = function () {
  933. return this.$newLineMode;
  934. };
  935. this.isNewLine = function (text) {
  936. return (text == "\r\n" || text == "\r" || text == "\n");
  937. };
  938. this.getLine = function (row) {
  939. return this.$lines[row] || "";
  940. };
  941. this.getLines = function (firstRow, lastRow) {
  942. return this.$lines.slice(firstRow, lastRow + 1);
  943. };
  944. this.getAllLines = function () {
  945. return this.getLines(0, this.getLength());
  946. };
  947. this.getLength = function () {
  948. return this.$lines.length;
  949. };
  950. this.getTextRange = function (range) {
  951. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  952. };
  953. this.getLinesForRange = function (range) {
  954. var lines;
  955. if (range.start.row === range.end.row) {
  956. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  957. }
  958. else {
  959. lines = this.getLines(range.start.row, range.end.row);
  960. lines[0] = (lines[0] || "").substring(range.start.column);
  961. var l = lines.length - 1;
  962. if (range.end.row - range.start.row == l)
  963. lines[l] = lines[l].substring(0, range.end.column);
  964. }
  965. return lines;
  966. };
  967. this.insertLines = function (row, lines) {
  968. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  969. return this.insertFullLines(row, lines);
  970. };
  971. this.removeLines = function (firstRow, lastRow) {
  972. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  973. return this.removeFullLines(firstRow, lastRow);
  974. };
  975. this.insertNewLine = function (position) {
  976. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  977. return this.insertMergedLines(position, ["", ""]);
  978. };
  979. this.insert = function (position, text) {
  980. if (this.getLength() <= 1)
  981. this.$detectNewLine(text);
  982. return this.insertMergedLines(position, this.$split(text));
  983. };
  984. this.insertInLine = function (position, text) {
  985. var start = this.clippedPos(position.row, position.column);
  986. var end = this.pos(position.row, position.column + text.length);
  987. this.applyDelta({
  988. start: start,
  989. end: end,
  990. action: "insert",
  991. lines: [text]
  992. }, true);
  993. return this.clonePos(end);
  994. };
  995. this.clippedPos = function (row, column) {
  996. var length = this.getLength();
  997. if (row === undefined) {
  998. row = length;
  999. }
  1000. else if (row < 0) {
  1001. row = 0;
  1002. }
  1003. else if (row >= length) {
  1004. row = length - 1;
  1005. column = undefined;
  1006. }
  1007. var line = this.getLine(row);
  1008. if (column == undefined)
  1009. column = line.length;
  1010. column = Math.min(Math.max(column, 0), line.length);
  1011. return { row: row, column: column };
  1012. };
  1013. this.clonePos = function (pos) {
  1014. return { row: pos.row, column: pos.column };
  1015. };
  1016. this.pos = function (row, column) {
  1017. return { row: row, column: column };
  1018. };
  1019. this.$clipPosition = function (position) {
  1020. var length = this.getLength();
  1021. if (position.row >= length) {
  1022. position.row = Math.max(0, length - 1);
  1023. position.column = this.getLine(length - 1).length;
  1024. }
  1025. else {
  1026. position.row = Math.max(0, position.row);
  1027. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  1028. }
  1029. return position;
  1030. };
  1031. this.insertFullLines = function (row, lines) {
  1032. row = Math.min(Math.max(row, 0), this.getLength());
  1033. var column = 0;
  1034. if (row < this.getLength()) {
  1035. lines = lines.concat([""]);
  1036. column = 0;
  1037. }
  1038. else {
  1039. lines = [""].concat(lines);
  1040. row--;
  1041. column = this.$lines[row].length;
  1042. }
  1043. this.insertMergedLines({ row: row, column: column }, lines);
  1044. };
  1045. this.insertMergedLines = function (position, lines) {
  1046. var start = this.clippedPos(position.row, position.column);
  1047. var end = {
  1048. row: start.row + lines.length - 1,
  1049. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  1050. };
  1051. this.applyDelta({
  1052. start: start,
  1053. end: end,
  1054. action: "insert",
  1055. lines: lines
  1056. });
  1057. return this.clonePos(end);
  1058. };
  1059. this.remove = function (range) {
  1060. var start = this.clippedPos(range.start.row, range.start.column);
  1061. var end = this.clippedPos(range.end.row, range.end.column);
  1062. this.applyDelta({
  1063. start: start,
  1064. end: end,
  1065. action: "remove",
  1066. lines: this.getLinesForRange({ start: start, end: end })
  1067. });
  1068. return this.clonePos(start);
  1069. };
  1070. this.removeInLine = function (row, startColumn, endColumn) {
  1071. var start = this.clippedPos(row, startColumn);
  1072. var end = this.clippedPos(row, endColumn);
  1073. this.applyDelta({
  1074. start: start,
  1075. end: end,
  1076. action: "remove",
  1077. lines: this.getLinesForRange({ start: start, end: end })
  1078. }, true);
  1079. return this.clonePos(start);
  1080. };
  1081. this.removeFullLines = function (firstRow, lastRow) {
  1082. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  1083. lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1);
  1084. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  1085. var deleteLastNewLine = lastRow < this.getLength() - 1;
  1086. var startRow = (deleteFirstNewLine ? firstRow - 1 : firstRow);
  1087. var startCol = (deleteFirstNewLine ? this.getLine(startRow).length : 0);
  1088. var endRow = (deleteLastNewLine ? lastRow + 1 : lastRow);
  1089. var endCol = (deleteLastNewLine ? 0 : this.getLine(endRow).length);
  1090. var range = new Range(startRow, startCol, endRow, endCol);
  1091. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  1092. this.applyDelta({
  1093. start: range.start,
  1094. end: range.end,
  1095. action: "remove",
  1096. lines: this.getLinesForRange(range)
  1097. });
  1098. return deletedLines;
  1099. };
  1100. this.removeNewLine = function (row) {
  1101. if (row < this.getLength() - 1 && row >= 0) {
  1102. this.applyDelta({
  1103. start: this.pos(row, this.getLine(row).length),
  1104. end: this.pos(row + 1, 0),
  1105. action: "remove",
  1106. lines: ["", ""]
  1107. });
  1108. }
  1109. };
  1110. this.replace = function (range, text) {
  1111. if (!(range instanceof Range))
  1112. range = Range.fromPoints(range.start, range.end);
  1113. if (text.length === 0 && range.isEmpty())
  1114. return range.start;
  1115. if (text == this.getTextRange(range))
  1116. return range.end;
  1117. this.remove(range);
  1118. var end;
  1119. if (text) {
  1120. end = this.insert(range.start, text);
  1121. }
  1122. else {
  1123. end = range.start;
  1124. }
  1125. return end;
  1126. };
  1127. this.applyDeltas = function (deltas) {
  1128. for (var i = 0; i < deltas.length; i++) {
  1129. this.applyDelta(deltas[i]);
  1130. }
  1131. };
  1132. this.revertDeltas = function (deltas) {
  1133. for (var i = deltas.length - 1; i >= 0; i--) {
  1134. this.revertDelta(deltas[i]);
  1135. }
  1136. };
  1137. this.applyDelta = function (delta, doNotValidate) {
  1138. var isInsert = delta.action == "insert";
  1139. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  1140. : !Range.comparePoints(delta.start, delta.end)) {
  1141. return;
  1142. }
  1143. if (isInsert && delta.lines.length > 20000) {
  1144. this.$splitAndapplyLargeDelta(delta, 20000);
  1145. }
  1146. else {
  1147. applyDelta(this.$lines, delta, doNotValidate);
  1148. this._signal("change", delta);
  1149. }
  1150. };
  1151. this.$safeApplyDelta = function (delta) {
  1152. var docLength = this.$lines.length;
  1153. if (delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
  1154. || delta.action == "insert" && delta.start.row <= docLength) {
  1155. this.applyDelta(delta);
  1156. }
  1157. };
  1158. this.$splitAndapplyLargeDelta = function (delta, MAX) {
  1159. var lines = delta.lines;
  1160. var l = lines.length - MAX + 1;
  1161. var row = delta.start.row;
  1162. var column = delta.start.column;
  1163. for (var from = 0, to = 0; from < l; from = to) {
  1164. to += MAX - 1;
  1165. var chunk = lines.slice(from, to);
  1166. chunk.push("");
  1167. this.applyDelta({
  1168. start: this.pos(row + from, column),
  1169. end: this.pos(row + to, column = 0),
  1170. action: delta.action,
  1171. lines: chunk
  1172. }, true);
  1173. }
  1174. delta.lines = lines.slice(from);
  1175. delta.start.row = row + from;
  1176. delta.start.column = column;
  1177. this.applyDelta(delta, true);
  1178. };
  1179. this.revertDelta = function (delta) {
  1180. this.$safeApplyDelta({
  1181. start: this.clonePos(delta.start),
  1182. end: this.clonePos(delta.end),
  1183. action: (delta.action == "insert" ? "remove" : "insert"),
  1184. lines: delta.lines.slice()
  1185. });
  1186. };
  1187. this.indexToPosition = function (index, startRow) {
  1188. var lines = this.$lines || this.getAllLines();
  1189. var newlineLength = this.getNewLineCharacter().length;
  1190. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1191. index -= lines[i].length + newlineLength;
  1192. if (index < 0)
  1193. return { row: i, column: index + lines[i].length + newlineLength };
  1194. }
  1195. return { row: l - 1, column: index + lines[l - 1].length + newlineLength };
  1196. };
  1197. this.positionToIndex = function (pos, startRow) {
  1198. var lines = this.$lines || this.getAllLines();
  1199. var newlineLength = this.getNewLineCharacter().length;
  1200. var index = 0;
  1201. var row = Math.min(pos.row, lines.length);
  1202. for (var i = startRow || 0; i < row; ++i)
  1203. index += lines[i].length + newlineLength;
  1204. return index + pos.column;
  1205. };
  1206. }).call(Document.prototype);
  1207. exports.Document = Document;
  1208. });
  1209. ace.define("ace/worker/mirror",[], function(require, exports, module) {
  1210. "use strict";
  1211. var Document = require("../document").Document;
  1212. var lang = require("../lib/lang");
  1213. var Mirror = exports.Mirror = function(sender) {
  1214. this.sender = sender;
  1215. var doc = this.doc = new Document("");
  1216. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1217. var _self = this;
  1218. sender.on("change", function(e) {
  1219. var data = e.data;
  1220. if (data[0].start) {
  1221. doc.applyDeltas(data);
  1222. } else {
  1223. for (var i = 0; i < data.length; i += 2) {
  1224. var d, err;
  1225. if (Array.isArray(data[i+1])) {
  1226. d = {action: "insert", start: data[i], lines: data[i+1]};
  1227. } else {
  1228. d = {action: "remove", start: data[i], end: data[i+1]};
  1229. }
  1230. if ((d.action == "insert" ? d.start : d.end).row >= doc.$lines.length) {
  1231. err = new Error("Invalid delta");
  1232. err.data = {
  1233. path: _self.$path,
  1234. linesLength: doc.$lines.length,
  1235. start: d.start,
  1236. end: d.end
  1237. };
  1238. throw err;
  1239. }
  1240. doc.applyDelta(d, true);
  1241. }
  1242. }
  1243. if (_self.$timeout)
  1244. return deferredUpdate.schedule(_self.$timeout);
  1245. _self.onUpdate();
  1246. });
  1247. };
  1248. (function() {
  1249. this.$timeout = 500;
  1250. this.setTimeout = function(timeout) {
  1251. this.$timeout = timeout;
  1252. };
  1253. this.setValue = function(value) {
  1254. this.doc.setValue(value);
  1255. this.deferredUpdate.schedule(this.$timeout);
  1256. };
  1257. this.getValue = function(callbackId) {
  1258. this.sender.callback(this.doc.getValue(), callbackId);
  1259. };
  1260. this.onUpdate = function() {
  1261. };
  1262. this.isPending = function() {
  1263. return this.deferredUpdate.isPending();
  1264. };
  1265. }).call(Mirror.prototype);
  1266. });
  1267. ace.define("ace/mode/css/csslint",[], function(require, exports, module) {
  1268. var CSSLint = (function(){
  1269. var module = module || {},
  1270. exports = exports || {};
  1271. var parserlib = (function () {
  1272. var require;
  1273. require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  1274. "use strict";
  1275. var Colors = module.exports = {
  1276. __proto__ : null,
  1277. aliceblue : "#f0f8ff",
  1278. antiquewhite : "#faebd7",
  1279. aqua : "#00ffff",
  1280. aquamarine : "#7fffd4",
  1281. azure : "#f0ffff",
  1282. beige : "#f5f5dc",
  1283. bisque : "#ffe4c4",
  1284. black : "#000000",
  1285. blanchedalmond : "#ffebcd",
  1286. blue : "#0000ff",
  1287. blueviolet : "#8a2be2",
  1288. brown : "#a52a2a",
  1289. burlywood : "#deb887",
  1290. cadetblue : "#5f9ea0",
  1291. chartreuse : "#7fff00",
  1292. chocolate : "#d2691e",
  1293. coral : "#ff7f50",
  1294. cornflowerblue : "#6495ed",
  1295. cornsilk : "#fff8dc",
  1296. crimson : "#dc143c",
  1297. cyan : "#00ffff",
  1298. darkblue : "#00008b",
  1299. darkcyan : "#008b8b",
  1300. darkgoldenrod : "#b8860b",
  1301. darkgray : "#a9a9a9",
  1302. darkgreen : "#006400",
  1303. darkgrey : "#a9a9a9",
  1304. darkkhaki : "#bdb76b",
  1305. darkmagenta : "#8b008b",
  1306. darkolivegreen : "#556b2f",
  1307. darkorange : "#ff8c00",
  1308. darkorchid : "#9932cc",
  1309. darkred : "#8b0000",
  1310. darksalmon : "#e9967a",
  1311. darkseagreen : "#8fbc8f",
  1312. darkslateblue : "#483d8b",
  1313. darkslategray : "#2f4f4f",
  1314. darkslategrey : "#2f4f4f",
  1315. darkturquoise : "#00ced1",
  1316. darkviolet : "#9400d3",
  1317. deeppink : "#ff1493",
  1318. deepskyblue : "#00bfff",
  1319. dimgray : "#696969",
  1320. dimgrey : "#696969",
  1321. dodgerblue : "#1e90ff",
  1322. firebrick : "#b22222",
  1323. floralwhite : "#fffaf0",
  1324. forestgreen : "#228b22",
  1325. fuchsia : "#ff00ff",
  1326. gainsboro : "#dcdcdc",
  1327. ghostwhite : "#f8f8ff",
  1328. gold : "#ffd700",
  1329. goldenrod : "#daa520",
  1330. gray : "#808080",
  1331. green : "#008000",
  1332. greenyellow : "#adff2f",
  1333. grey : "#808080",
  1334. honeydew : "#f0fff0",
  1335. hotpink : "#ff69b4",
  1336. indianred : "#cd5c5c",
  1337. indigo : "#4b0082",
  1338. ivory : "#fffff0",
  1339. khaki : "#f0e68c",
  1340. lavender : "#e6e6fa",
  1341. lavenderblush : "#fff0f5",
  1342. lawngreen : "#7cfc00",
  1343. lemonchiffon : "#fffacd",
  1344. lightblue : "#add8e6",
  1345. lightcoral : "#f08080",
  1346. lightcyan : "#e0ffff",
  1347. lightgoldenrodyellow : "#fafad2",
  1348. lightgray : "#d3d3d3",
  1349. lightgreen : "#90ee90",
  1350. lightgrey : "#d3d3d3",
  1351. lightpink : "#ffb6c1",
  1352. lightsalmon : "#ffa07a",
  1353. lightseagreen : "#20b2aa",
  1354. lightskyblue : "#87cefa",
  1355. lightslategray : "#778899",
  1356. lightslategrey : "#778899",
  1357. lightsteelblue : "#b0c4de",
  1358. lightyellow : "#ffffe0",
  1359. lime : "#00ff00",
  1360. limegreen : "#32cd32",
  1361. linen : "#faf0e6",
  1362. magenta : "#ff00ff",
  1363. maroon : "#800000",
  1364. mediumaquamarine : "#66cdaa",
  1365. mediumblue : "#0000cd",
  1366. mediumorchid : "#ba55d3",
  1367. mediumpurple : "#9370db",
  1368. mediumseagreen : "#3cb371",
  1369. mediumslateblue : "#7b68ee",
  1370. mediumspringgreen : "#00fa9a",
  1371. mediumturquoise : "#48d1cc",
  1372. mediumvioletred : "#c71585",
  1373. midnightblue : "#191970",
  1374. mintcream : "#f5fffa",
  1375. mistyrose : "#ffe4e1",
  1376. moccasin : "#ffe4b5",
  1377. navajowhite : "#ffdead",
  1378. navy : "#000080",
  1379. oldlace : "#fdf5e6",
  1380. olive : "#808000",
  1381. olivedrab : "#6b8e23",
  1382. orange : "#ffa500",
  1383. orangered : "#ff4500",
  1384. orchid : "#da70d6",
  1385. palegoldenrod : "#eee8aa",
  1386. palegreen : "#98fb98",
  1387. paleturquoise : "#afeeee",
  1388. palevioletred : "#db7093",
  1389. papayawhip : "#ffefd5",
  1390. peachpuff : "#ffdab9",
  1391. peru : "#cd853f",
  1392. pink : "#ffc0cb",
  1393. plum : "#dda0dd",
  1394. powderblue : "#b0e0e6",
  1395. purple : "#800080",
  1396. rebeccapurple : "#663399",
  1397. red : "#ff0000",
  1398. rosybrown : "#bc8f8f",
  1399. royalblue : "#4169e1",
  1400. saddlebrown : "#8b4513",
  1401. salmon : "#fa8072",
  1402. sandybrown : "#f4a460",
  1403. seagreen : "#2e8b57",
  1404. seashell : "#fff5ee",
  1405. sienna : "#a0522d",
  1406. silver : "#c0c0c0",
  1407. skyblue : "#87ceeb",
  1408. slateblue : "#6a5acd",
  1409. slategray : "#708090",
  1410. slategrey : "#708090",
  1411. snow : "#fffafa",
  1412. springgreen : "#00ff7f",
  1413. steelblue : "#4682b4",
  1414. tan : "#d2b48c",
  1415. teal : "#008080",
  1416. thistle : "#d8bfd8",
  1417. tomato : "#ff6347",
  1418. turquoise : "#40e0d0",
  1419. violet : "#ee82ee",
  1420. wheat : "#f5deb3",
  1421. white : "#ffffff",
  1422. whitesmoke : "#f5f5f5",
  1423. yellow : "#ffff00",
  1424. yellowgreen : "#9acd32",
  1425. currentColor : "The value of the 'color' property.",
  1426. activeborder : "Active window border.",
  1427. activecaption : "Active window caption.",
  1428. appworkspace : "Background color of multiple document interface.",
  1429. background : "Desktop background.",
  1430. buttonface : "The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1431. buttonhighlight : "The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1432. buttonshadow : "The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1433. buttontext : "Text on push buttons.",
  1434. captiontext : "Text in caption, size box, and scrollbar arrow box.",
  1435. graytext : "Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
  1436. greytext : "Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
  1437. highlight : "Item(s) selected in a control.",
  1438. highlighttext : "Text of item(s) selected in a control.",
  1439. inactiveborder : "Inactive window border.",
  1440. inactivecaption : "Inactive window caption.",
  1441. inactivecaptiontext : "Color of text in an inactive caption.",
  1442. infobackground : "Background color for tooltip controls.",
  1443. infotext : "Text color for tooltip controls.",
  1444. menu : "Menu background.",
  1445. menutext : "Text in menus.",
  1446. scrollbar : "Scroll bar gray area.",
  1447. threeddarkshadow : "The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1448. threedface : "The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1449. threedhighlight : "The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1450. threedlightshadow : "The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1451. threedshadow : "The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1452. window : "Window background.",
  1453. windowframe : "Window frame.",
  1454. windowtext : "Text in windows."
  1455. };
  1456. },{}],2:[function(require,module,exports){
  1457. "use strict";
  1458. module.exports = Combinator;
  1459. var SyntaxUnit = require("../util/SyntaxUnit");
  1460. var Parser = require("./Parser");
  1461. function Combinator(text, line, col) {
  1462. SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
  1463. this.type = "unknown";
  1464. if (/^\s+$/.test(text)) {
  1465. this.type = "descendant";
  1466. } else if (text === ">") {
  1467. this.type = "child";
  1468. } else if (text === "+") {
  1469. this.type = "adjacent-sibling";
  1470. } else if (text === "~") {
  1471. this.type = "sibling";
  1472. }
  1473. }
  1474. Combinator.prototype = new SyntaxUnit();
  1475. Combinator.prototype.constructor = Combinator;
  1476. },{"../util/SyntaxUnit":26,"./Parser":6}],3:[function(require,module,exports){
  1477. "use strict";
  1478. module.exports = Matcher;
  1479. var StringReader = require("../util/StringReader");
  1480. var SyntaxError = require("../util/SyntaxError");
  1481. function Matcher(matchFunc, toString) {
  1482. this.match = function(expression) {
  1483. var result;
  1484. expression.mark();
  1485. result = matchFunc(expression);
  1486. if (result) {
  1487. expression.drop();
  1488. } else {
  1489. expression.restore();
  1490. }
  1491. return result;
  1492. };
  1493. this.toString = typeof toString === "function" ? toString : function() {
  1494. return toString;
  1495. };
  1496. }
  1497. Matcher.prec = {
  1498. MOD: 5,
  1499. SEQ: 4,
  1500. ANDAND: 3,
  1501. OROR: 2,
  1502. ALT: 1
  1503. };
  1504. Matcher.parse = function(str) {
  1505. var reader, eat, expr, oror, andand, seq, mod, term, result;
  1506. reader = new StringReader(str);
  1507. eat = function(matcher) {
  1508. var result = reader.readMatch(matcher);
  1509. if (result === null) {
  1510. throw new SyntaxError(
  1511. "Expected " + matcher, reader.getLine(), reader.getCol());
  1512. }
  1513. return result;
  1514. };
  1515. expr = function() {
  1516. var m = [ oror() ];
  1517. while (reader.readMatch(" | ") !== null) {
  1518. m.push(oror());
  1519. }
  1520. return m.length === 1 ? m[0] : Matcher.alt.apply(Matcher, m);
  1521. };
  1522. oror = function() {
  1523. var m = [ andand() ];
  1524. while (reader.readMatch(" || ") !== null) {
  1525. m.push(andand());
  1526. }
  1527. return m.length === 1 ? m[0] : Matcher.oror.apply(Matcher, m);
  1528. };
  1529. andand = function() {
  1530. var m = [ seq() ];
  1531. while (reader.readMatch(" && ") !== null) {
  1532. m.push(seq());
  1533. }
  1534. return m.length === 1 ? m[0] : Matcher.andand.apply(Matcher, m);
  1535. };
  1536. seq = function() {
  1537. var m = [ mod() ];
  1538. while (reader.readMatch(/^ (?![&|\]])/) !== null) {
  1539. m.push(mod());
  1540. }
  1541. return m.length === 1 ? m[0] : Matcher.seq.apply(Matcher, m);
  1542. };
  1543. mod = function() {
  1544. var m = term();
  1545. if (reader.readMatch("?") !== null) {
  1546. return m.question();
  1547. } else if (reader.readMatch("*") !== null) {
  1548. return m.star();
  1549. } else if (reader.readMatch("+") !== null) {
  1550. return m.plus();
  1551. } else if (reader.readMatch("#") !== null) {
  1552. return m.hash();
  1553. } else if (reader.readMatch(/^\{\s*/) !== null) {
  1554. var min = eat(/^\d+/);
  1555. eat(/^\s*,\s*/);
  1556. var max = eat(/^\d+/);
  1557. eat(/^\s*\}/);
  1558. return m.braces(Number(min), Number(max));
  1559. }
  1560. return m;
  1561. };
  1562. term = function() {
  1563. if (reader.readMatch("[ ") !== null) {
  1564. var m = expr();
  1565. eat(" ]");
  1566. return m;
  1567. }
  1568. return Matcher.fromType(eat(/^[^ ?*+#{]+/));
  1569. };
  1570. result = expr();
  1571. if (!reader.eof()) {
  1572. throw new SyntaxError(
  1573. "Expected end of string", reader.getLine(), reader.getCol());
  1574. }
  1575. return result;
  1576. };
  1577. Matcher.cast = function(m) {
  1578. if (m instanceof Matcher) {
  1579. return m;
  1580. }
  1581. return Matcher.parse(m);
  1582. };
  1583. Matcher.fromType = function(type) {
  1584. var ValidationTypes = require("./ValidationTypes");
  1585. return new Matcher(function(expression) {
  1586. return expression.hasNext() && ValidationTypes.isType(expression, type);
  1587. }, type);
  1588. };
  1589. Matcher.seq = function() {
  1590. var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
  1591. if (ms.length === 1) {
  1592. return ms[0];
  1593. }
  1594. return new Matcher(function(expression) {
  1595. var i, result = true;
  1596. for (i = 0; result && i < ms.length; i++) {
  1597. result = ms[i].match(expression);
  1598. }
  1599. return result;
  1600. }, function(prec) {
  1601. var p = Matcher.prec.SEQ;
  1602. var s = ms.map(function(m) {
  1603. return m.toString(p);
  1604. }).join(" ");
  1605. if (prec > p) {
  1606. s = "[ " + s + " ]";
  1607. }
  1608. return s;
  1609. });
  1610. };
  1611. Matcher.alt = function() {
  1612. var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
  1613. if (ms.length === 1) {
  1614. return ms[0];
  1615. }
  1616. return new Matcher(function(expression) {
  1617. var i, result = false;
  1618. for (i = 0; !result && i < ms.length; i++) {
  1619. result = ms[i].match(expression);
  1620. }
  1621. return result;
  1622. }, function(prec) {
  1623. var p = Matcher.prec.ALT;
  1624. var s = ms.map(function(m) {
  1625. return m.toString(p);
  1626. }).join(" | ");
  1627. if (prec > p) {
  1628. s = "[ " + s + " ]";
  1629. }
  1630. return s;
  1631. });
  1632. };
  1633. Matcher.many = function(required) {
  1634. var ms = Array.prototype.slice.call(arguments, 1).reduce(function(acc, v) {
  1635. if (v.expand) {
  1636. var ValidationTypes = require("./ValidationTypes");
  1637. acc.push.apply(acc, ValidationTypes.complex[v.expand].options);
  1638. } else {
  1639. acc.push(Matcher.cast(v));
  1640. }
  1641. return acc;
  1642. }, []);
  1643. if (required === true) {
  1644. required = ms.map(function() {
  1645. return true;
  1646. });
  1647. }
  1648. var result = new Matcher(function(expression) {
  1649. var seen = [], max = 0, pass = 0;
  1650. var success = function(matchCount) {
  1651. if (pass === 0) {
  1652. max = Math.max(matchCount, max);
  1653. return matchCount === ms.length;
  1654. } else {
  1655. return matchCount === max;
  1656. }
  1657. };
  1658. var tryMatch = function(matchCount) {
  1659. for (var i = 0; i < ms.length; i++) {
  1660. if (seen[i]) {
  1661. continue;
  1662. }
  1663. expression.mark();
  1664. if (ms[i].match(expression)) {
  1665. seen[i] = true;
  1666. if (tryMatch(matchCount + (required === false || required[i] ? 1 : 0))) {
  1667. expression.drop();
  1668. return true;
  1669. }
  1670. expression.restore();
  1671. seen[i] = false;
  1672. } else {
  1673. expression.drop();
  1674. }
  1675. }
  1676. return success(matchCount);
  1677. };
  1678. if (!tryMatch(0)) {
  1679. pass++;
  1680. tryMatch(0);
  1681. }
  1682. if (required === false) {
  1683. return max > 0;
  1684. }
  1685. for (var i = 0; i < ms.length; i++) {
  1686. if (required[i] && !seen[i]) {
  1687. return false;
  1688. }
  1689. }
  1690. return true;
  1691. }, function(prec) {
  1692. var p = required === false ? Matcher.prec.OROR : Matcher.prec.ANDAND;
  1693. var s = ms.map(function(m, i) {
  1694. if (required !== false && !required[i]) {
  1695. return m.toString(Matcher.prec.MOD) + "?";
  1696. }
  1697. return m.toString(p);
  1698. }).join(required === false ? " || " : " && ");
  1699. if (prec > p) {
  1700. s = "[ " + s + " ]";
  1701. }
  1702. return s;
  1703. });
  1704. result.options = ms;
  1705. return result;
  1706. };
  1707. Matcher.andand = function() {
  1708. var args = Array.prototype.slice.call(arguments);
  1709. args.unshift(true);
  1710. return Matcher.many.apply(Matcher, args);
  1711. };
  1712. Matcher.oror = function() {
  1713. var args = Array.prototype.slice.call(arguments);
  1714. args.unshift(false);
  1715. return Matcher.many.apply(Matcher, args);
  1716. };
  1717. Matcher.prototype = {
  1718. constructor: Matcher,
  1719. match: function() {
  1720. throw new Error("unimplemented");
  1721. },
  1722. toString: function() {
  1723. throw new Error("unimplemented");
  1724. },
  1725. func: function() {
  1726. return this.match.bind(this);
  1727. },
  1728. then: function(m) {
  1729. return Matcher.seq(this, m);
  1730. },
  1731. or: function(m) {
  1732. return Matcher.alt(this, m);
  1733. },
  1734. andand: function(m) {
  1735. return Matcher.many(true, this, m);
  1736. },
  1737. oror: function(m) {
  1738. return Matcher.many(false, this, m);
  1739. },
  1740. star: function() {
  1741. return this.braces(0, Infinity, "*");
  1742. },
  1743. plus: function() {
  1744. return this.braces(1, Infinity, "+");
  1745. },
  1746. question: function() {
  1747. return this.braces(0, 1, "?");
  1748. },
  1749. hash: function() {
  1750. return this.braces(1, Infinity, "#", Matcher.cast(","));
  1751. },
  1752. braces: function(min, max, marker, optSep) {
  1753. var m1 = this, m2 = optSep ? optSep.then(this) : this;
  1754. if (!marker) {
  1755. marker = "{" + min + "," + max + "}";
  1756. }
  1757. return new Matcher(function(expression) {
  1758. var result = true, i;
  1759. for (i = 0; i < max; i++) {
  1760. if (i > 0 && optSep) {
  1761. result = m2.match(expression);
  1762. } else {
  1763. result = m1.match(expression);
  1764. }
  1765. if (!result) {
  1766. break;
  1767. }
  1768. }
  1769. return i >= min;
  1770. }, function() {
  1771. return m1.toString(Matcher.prec.MOD) + marker;
  1772. });
  1773. }
  1774. };
  1775. },{"../util/StringReader":24,"../util/SyntaxError":25,"./ValidationTypes":21}],4:[function(require,module,exports){
  1776. "use strict";
  1777. module.exports = MediaFeature;
  1778. var SyntaxUnit = require("../util/SyntaxUnit");
  1779. var Parser = require("./Parser");
  1780. function MediaFeature(name, value) {
  1781. SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
  1782. this.name = name;
  1783. this.value = value;
  1784. }
  1785. MediaFeature.prototype = new SyntaxUnit();
  1786. MediaFeature.prototype.constructor = MediaFeature;
  1787. },{"../util/SyntaxUnit":26,"./Parser":6}],5:[function(require,module,exports){
  1788. "use strict";
  1789. module.exports = MediaQuery;
  1790. var SyntaxUnit = require("../util/SyntaxUnit");
  1791. var Parser = require("./Parser");
  1792. function MediaQuery(modifier, mediaType, features, line, col) {
  1793. SyntaxUnit.call(this, (modifier ? modifier + " " : "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
  1794. this.modifier = modifier;
  1795. this.mediaType = mediaType;
  1796. this.features = features;
  1797. }
  1798. MediaQuery.prototype = new SyntaxUnit();
  1799. MediaQuery.prototype.constructor = MediaQuery;
  1800. },{"../util/SyntaxUnit":26,"./Parser":6}],6:[function(require,module,exports){
  1801. "use strict";
  1802. module.exports = Parser;
  1803. var EventTarget = require("../util/EventTarget");
  1804. var SyntaxError = require("../util/SyntaxError");
  1805. var SyntaxUnit = require("../util/SyntaxUnit");
  1806. var Combinator = require("./Combinator");
  1807. var MediaFeature = require("./MediaFeature");
  1808. var MediaQuery = require("./MediaQuery");
  1809. var PropertyName = require("./PropertyName");
  1810. var PropertyValue = require("./PropertyValue");
  1811. var PropertyValuePart = require("./PropertyValuePart");
  1812. var Selector = require("./Selector");
  1813. var SelectorPart = require("./SelectorPart");
  1814. var SelectorSubPart = require("./SelectorSubPart");
  1815. var TokenStream = require("./TokenStream");
  1816. var Tokens = require("./Tokens");
  1817. var Validation = require("./Validation");
  1818. function Parser(options) {
  1819. EventTarget.call(this);
  1820. this.options = options || {};
  1821. this._tokenStream = null;
  1822. }
  1823. Parser.DEFAULT_TYPE = 0;
  1824. Parser.COMBINATOR_TYPE = 1;
  1825. Parser.MEDIA_FEATURE_TYPE = 2;
  1826. Parser.MEDIA_QUERY_TYPE = 3;
  1827. Parser.PROPERTY_NAME_TYPE = 4;
  1828. Parser.PROPERTY_VALUE_TYPE = 5;
  1829. Parser.PROPERTY_VALUE_PART_TYPE = 6;
  1830. Parser.SELECTOR_TYPE = 7;
  1831. Parser.SELECTOR_PART_TYPE = 8;
  1832. Parser.SELECTOR_SUB_PART_TYPE = 9;
  1833. Parser.prototype = function() {
  1834. var proto = new EventTarget(), // new prototype
  1835. prop,
  1836. additions = {
  1837. __proto__: null,
  1838. constructor: Parser,
  1839. DEFAULT_TYPE : 0,
  1840. COMBINATOR_TYPE : 1,
  1841. MEDIA_FEATURE_TYPE : 2,
  1842. MEDIA_QUERY_TYPE : 3,
  1843. PROPERTY_NAME_TYPE : 4,
  1844. PROPERTY_VALUE_TYPE : 5,
  1845. PROPERTY_VALUE_PART_TYPE : 6,
  1846. SELECTOR_TYPE : 7,
  1847. SELECTOR_PART_TYPE : 8,
  1848. SELECTOR_SUB_PART_TYPE : 9,
  1849. _stylesheet: function() {
  1850. var tokenStream = this._tokenStream,
  1851. count,
  1852. token,
  1853. tt;
  1854. this.fire("startstylesheet");
  1855. this._charset();
  1856. this._skipCruft();
  1857. while (tokenStream.peek() === Tokens.IMPORT_SYM) {
  1858. this._import();
  1859. this._skipCruft();
  1860. }
  1861. while (tokenStream.peek() === Tokens.NAMESPACE_SYM) {
  1862. this._namespace();
  1863. this._skipCruft();
  1864. }
  1865. tt = tokenStream.peek();
  1866. while (tt > Tokens.EOF) {
  1867. try {
  1868. switch (tt) {
  1869. case Tokens.MEDIA_SYM:
  1870. this._media();
  1871. this._skipCruft();
  1872. break;
  1873. case Tokens.PAGE_SYM:
  1874. this._page();
  1875. this._skipCruft();
  1876. break;
  1877. case Tokens.FONT_FACE_SYM:
  1878. this._font_face();
  1879. this._skipCruft();
  1880. break;
  1881. case Tokens.KEYFRAMES_SYM:
  1882. this._keyframes();
  1883. this._skipCruft();
  1884. break;
  1885. case Tokens.VIEWPORT_SYM:
  1886. this._viewport();
  1887. this._skipCruft();
  1888. break;
  1889. case Tokens.DOCUMENT_SYM:
  1890. this._document();
  1891. this._skipCruft();
  1892. break;
  1893. case Tokens.SUPPORTS_SYM:
  1894. this._supports();
  1895. this._skipCruft();
  1896. break;
  1897. case Tokens.UNKNOWN_SYM: // unknown @ rule
  1898. tokenStream.get();
  1899. if (!this.options.strict) {
  1900. this.fire({
  1901. type: "error",
  1902. error: null,
  1903. message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
  1904. line: tokenStream.LT(0).startLine,
  1905. col: tokenStream.LT(0).startCol
  1906. });
  1907. count = 0;
  1908. while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE) {
  1909. count++; // keep track of nesting depth
  1910. }
  1911. while (count) {
  1912. tokenStream.advance([Tokens.RBRACE]);
  1913. count--;
  1914. }
  1915. } else {
  1916. throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
  1917. }
  1918. break;
  1919. case Tokens.S:
  1920. this._readWhitespace();
  1921. break;
  1922. default:
  1923. if (!this._ruleset()) {
  1924. switch (tt) {
  1925. case Tokens.CHARSET_SYM:
  1926. token = tokenStream.LT(1);
  1927. this._charset(false);
  1928. throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
  1929. case Tokens.IMPORT_SYM:
  1930. token = tokenStream.LT(1);
  1931. this._import(false);
  1932. throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
  1933. case Tokens.NAMESPACE_SYM:
  1934. token = tokenStream.LT(1);
  1935. this._namespace(false);
  1936. throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
  1937. default:
  1938. tokenStream.get(); // get the last token
  1939. this._unexpectedToken(tokenStream.token());
  1940. }
  1941. }
  1942. }
  1943. } catch (ex) {
  1944. if (ex instanceof SyntaxError && !this.options.strict) {
  1945. this.fire({
  1946. type: "error",
  1947. error: ex,
  1948. message: ex.message,
  1949. line: ex.line,
  1950. col: ex.col
  1951. });
  1952. } else {
  1953. throw ex;
  1954. }
  1955. }
  1956. tt = tokenStream.peek();
  1957. }
  1958. if (tt !== Tokens.EOF) {
  1959. this._unexpectedToken(tokenStream.token());
  1960. }
  1961. this.fire("endstylesheet");
  1962. },
  1963. _charset: function(emit) {
  1964. var tokenStream = this._tokenStream,
  1965. charset,
  1966. token,
  1967. line,
  1968. col;
  1969. if (tokenStream.match(Tokens.CHARSET_SYM)) {
  1970. line = tokenStream.token().startLine;
  1971. col = tokenStream.token().startCol;
  1972. this._readWhitespace();
  1973. tokenStream.mustMatch(Tokens.STRING);
  1974. token = tokenStream.token();
  1975. charset = token.value;
  1976. this._readWhitespace();
  1977. tokenStream.mustMatch(Tokens.SEMICOLON);
  1978. if (emit !== false) {
  1979. this.fire({
  1980. type: "charset",
  1981. charset:charset,
  1982. line: line,
  1983. col: col
  1984. });
  1985. }
  1986. }
  1987. },
  1988. _import: function(emit) {
  1989. var tokenStream = this._tokenStream,
  1990. uri,
  1991. importToken,
  1992. mediaList = [];
  1993. tokenStream.mustMatch(Tokens.IMPORT_SYM);
  1994. importToken = tokenStream.token();
  1995. this._readWhitespace();
  1996. tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
  1997. uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");
  1998. this._readWhitespace();
  1999. mediaList = this._media_query_list();
  2000. tokenStream.mustMatch(Tokens.SEMICOLON);
  2001. this._readWhitespace();
  2002. if (emit !== false) {
  2003. this.fire({
  2004. type: "import",
  2005. uri: uri,
  2006. media: mediaList,
  2007. line: importToken.startLine,
  2008. col: importToken.startCol
  2009. });
  2010. }
  2011. },
  2012. _namespace: function(emit) {
  2013. var tokenStream = this._tokenStream,
  2014. line,
  2015. col,
  2016. prefix,
  2017. uri;
  2018. tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
  2019. line = tokenStream.token().startLine;
  2020. col = tokenStream.token().startCol;
  2021. this._readWhitespace();
  2022. if (tokenStream.match(Tokens.IDENT)) {
  2023. prefix = tokenStream.token().value;
  2024. this._readWhitespace();
  2025. }
  2026. tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
  2027. uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
  2028. this._readWhitespace();
  2029. tokenStream.mustMatch(Tokens.SEMICOLON);
  2030. this._readWhitespace();
  2031. if (emit !== false) {
  2032. this.fire({
  2033. type: "namespace",
  2034. prefix: prefix,
  2035. uri: uri,
  2036. line: line,
  2037. col: col
  2038. });
  2039. }
  2040. },
  2041. _supports: function(emit) {
  2042. var tokenStream = this._tokenStream,
  2043. line,
  2044. col;
  2045. if (tokenStream.match(Tokens.SUPPORTS_SYM)) {
  2046. line = tokenStream.token().startLine;
  2047. col = tokenStream.token().startCol;
  2048. this._readWhitespace();
  2049. this._supports_condition();
  2050. this._readWhitespace();
  2051. tokenStream.mustMatch(Tokens.LBRACE);
  2052. this._readWhitespace();
  2053. if (emit !== false) {
  2054. this.fire({
  2055. type: "startsupports",
  2056. line: line,
  2057. col: col
  2058. });
  2059. }
  2060. while (true) {
  2061. if (!this._ruleset()) {
  2062. break;
  2063. }
  2064. }
  2065. tokenStream.mustMatch(Tokens.RBRACE);
  2066. this._readWhitespace();
  2067. this.fire({
  2068. type: "endsupports",
  2069. line: line,
  2070. col: col
  2071. });
  2072. }
  2073. },
  2074. _supports_condition: function() {
  2075. var tokenStream = this._tokenStream,
  2076. ident;
  2077. if (tokenStream.match(Tokens.IDENT)) {
  2078. ident = tokenStream.token().value.toLowerCase();
  2079. if (ident === "not") {
  2080. tokenStream.mustMatch(Tokens.S);
  2081. this._supports_condition_in_parens();
  2082. } else {
  2083. tokenStream.unget();
  2084. }
  2085. } else {
  2086. this._supports_condition_in_parens();
  2087. this._readWhitespace();
  2088. while (tokenStream.peek() === Tokens.IDENT) {
  2089. ident = tokenStream.LT(1).value.toLowerCase();
  2090. if (ident === "and" || ident === "or") {
  2091. tokenStream.mustMatch(Tokens.IDENT);
  2092. this._readWhitespace();
  2093. this._supports_condition_in_parens();
  2094. this._readWhitespace();
  2095. }
  2096. }
  2097. }
  2098. },
  2099. _supports_condition_in_parens: function() {
  2100. var tokenStream = this._tokenStream,
  2101. ident;
  2102. if (tokenStream.match(Tokens.LPAREN)) {
  2103. this._readWhitespace();
  2104. if (tokenStream.match(Tokens.IDENT)) {
  2105. ident = tokenStream.token().value.toLowerCase();
  2106. if (ident === "not") {
  2107. this._readWhitespace();
  2108. this._supports_condition();
  2109. this._readWhitespace();
  2110. tokenStream.mustMatch(Tokens.RPAREN);
  2111. } else {
  2112. tokenStream.unget();
  2113. this._supports_declaration_condition(false);
  2114. }
  2115. } else {
  2116. this._supports_condition();
  2117. this._readWhitespace();
  2118. tokenStream.mustMatch(Tokens.RPAREN);
  2119. }
  2120. } else {
  2121. this._supports_declaration_condition();
  2122. }
  2123. },
  2124. _supports_declaration_condition: function(requireStartParen) {
  2125. var tokenStream = this._tokenStream;
  2126. if (requireStartParen !== false) {
  2127. tokenStream.mustMatch(Tokens.LPAREN);
  2128. }
  2129. this._readWhitespace();
  2130. this._declaration();
  2131. tokenStream.mustMatch(Tokens.RPAREN);
  2132. },
  2133. _media: function() {
  2134. var tokenStream = this._tokenStream,
  2135. line,
  2136. col,
  2137. mediaList; // = [];
  2138. tokenStream.mustMatch(Tokens.MEDIA_SYM);
  2139. line = tokenStream.token().startLine;
  2140. col = tokenStream.token().startCol;
  2141. this._readWhitespace();
  2142. mediaList = this._media_query_list();
  2143. tokenStream.mustMatch(Tokens.LBRACE);
  2144. this._readWhitespace();
  2145. this.fire({
  2146. type: "startmedia",
  2147. media: mediaList,
  2148. line: line,
  2149. col: col
  2150. });
  2151. while (true) {
  2152. if (tokenStream.peek() === Tokens.PAGE_SYM) {
  2153. this._page();
  2154. } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM) {
  2155. this._font_face();
  2156. } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM) {
  2157. this._viewport();
  2158. } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM) {
  2159. this._document();
  2160. } else if (tokenStream.peek() === Tokens.SUPPORTS_SYM) {
  2161. this._supports();
  2162. } else if (tokenStream.peek() === Tokens.MEDIA_SYM) {
  2163. this._media();
  2164. } else if (!this._ruleset()) {
  2165. break;
  2166. }
  2167. }
  2168. tokenStream.mustMatch(Tokens.RBRACE);
  2169. this._readWhitespace();
  2170. this.fire({
  2171. type: "endmedia",
  2172. media: mediaList,
  2173. line: line,
  2174. col: col
  2175. });
  2176. },
  2177. _media_query_list: function() {
  2178. var tokenStream = this._tokenStream,
  2179. mediaList = [];
  2180. this._readWhitespace();
  2181. if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN) {
  2182. mediaList.push(this._media_query());
  2183. }
  2184. while (tokenStream.match(Tokens.COMMA)) {
  2185. this._readWhitespace();
  2186. mediaList.push(this._media_query());
  2187. }
  2188. return mediaList;
  2189. },
  2190. _media_query: function() {
  2191. var tokenStream = this._tokenStream,
  2192. type = null,
  2193. ident = null,
  2194. token = null,
  2195. expressions = [];
  2196. if (tokenStream.match(Tokens.IDENT)) {
  2197. ident = tokenStream.token().value.toLowerCase();
  2198. if (ident !== "only" && ident !== "not") {
  2199. tokenStream.unget();
  2200. ident = null;
  2201. } else {
  2202. token = tokenStream.token();
  2203. }
  2204. }
  2205. this._readWhitespace();
  2206. if (tokenStream.peek() === Tokens.IDENT) {
  2207. type = this._media_type();
  2208. if (token === null) {
  2209. token = tokenStream.token();
  2210. }
  2211. } else if (tokenStream.peek() === Tokens.LPAREN) {
  2212. if (token === null) {
  2213. token = tokenStream.LT(1);
  2214. }
  2215. expressions.push(this._media_expression());
  2216. }
  2217. if (type === null && expressions.length === 0) {
  2218. return null;
  2219. } else {
  2220. this._readWhitespace();
  2221. while (tokenStream.match(Tokens.IDENT)) {
  2222. if (tokenStream.token().value.toLowerCase() !== "and") {
  2223. this._unexpectedToken(tokenStream.token());
  2224. }
  2225. this._readWhitespace();
  2226. expressions.push(this._media_expression());
  2227. }
  2228. }
  2229. return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
  2230. },
  2231. _media_type: function() {
  2232. return this._media_feature();
  2233. },
  2234. _media_expression: function() {
  2235. var tokenStream = this._tokenStream,
  2236. feature = null,
  2237. token,
  2238. expression = null;
  2239. tokenStream.mustMatch(Tokens.LPAREN);
  2240. this._readWhitespace();
  2241. feature = this._media_feature();
  2242. this._readWhitespace();
  2243. if (tokenStream.match(Tokens.COLON)) {
  2244. this._readWhitespace();
  2245. token = tokenStream.LT(1);
  2246. expression = this._expression();
  2247. }
  2248. tokenStream.mustMatch(Tokens.RPAREN);
  2249. this._readWhitespace();
  2250. return new MediaFeature(feature, expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null);
  2251. },
  2252. _media_feature: function() {
  2253. var tokenStream = this._tokenStream;
  2254. this._readWhitespace();
  2255. tokenStream.mustMatch(Tokens.IDENT);
  2256. return SyntaxUnit.fromToken(tokenStream.token());
  2257. },
  2258. _page: function() {
  2259. var tokenStream = this._tokenStream,
  2260. line,
  2261. col,
  2262. identifier = null,
  2263. pseudoPage = null;
  2264. tokenStream.mustMatch(Tokens.PAGE_SYM);
  2265. line = tokenStream.token().startLine;
  2266. col = tokenStream.token().startCol;
  2267. this._readWhitespace();
  2268. if (tokenStream.match(Tokens.IDENT)) {
  2269. identifier = tokenStream.token().value;
  2270. if (identifier.toLowerCase() === "auto") {
  2271. this._unexpectedToken(tokenStream.token());
  2272. }
  2273. }
  2274. if (tokenStream.peek() === Tokens.COLON) {
  2275. pseudoPage = this._pseudo_page();
  2276. }
  2277. this._readWhitespace();
  2278. this.fire({
  2279. type: "startpage",
  2280. id: identifier,
  2281. pseudo: pseudoPage,
  2282. line: line,
  2283. col: col
  2284. });
  2285. this._readDeclarations(true, true);
  2286. this.fire({
  2287. type: "endpage",
  2288. id: identifier,
  2289. pseudo: pseudoPage,
  2290. line: line,
  2291. col: col
  2292. });
  2293. },
  2294. _margin: function() {
  2295. var tokenStream = this._tokenStream,
  2296. line,
  2297. col,
  2298. marginSym = this._margin_sym();
  2299. if (marginSym) {
  2300. line = tokenStream.token().startLine;
  2301. col = tokenStream.token().startCol;
  2302. this.fire({
  2303. type: "startpagemargin",
  2304. margin: marginSym,
  2305. line: line,
  2306. col: col
  2307. });
  2308. this._readDeclarations(true);
  2309. this.fire({
  2310. type: "endpagemargin",
  2311. margin: marginSym,
  2312. line: line,
  2313. col: col
  2314. });
  2315. return true;
  2316. } else {
  2317. return false;
  2318. }
  2319. },
  2320. _margin_sym: function() {
  2321. var tokenStream = this._tokenStream;
  2322. if (tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
  2323. Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
  2324. Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
  2325. Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
  2326. Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
  2327. Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
  2328. Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) {
  2329. return SyntaxUnit.fromToken(tokenStream.token());
  2330. } else {
  2331. return null;
  2332. }
  2333. },
  2334. _pseudo_page: function() {
  2335. var tokenStream = this._tokenStream;
  2336. tokenStream.mustMatch(Tokens.COLON);
  2337. tokenStream.mustMatch(Tokens.IDENT);
  2338. return tokenStream.token().value;
  2339. },
  2340. _font_face: function() {
  2341. var tokenStream = this._tokenStream,
  2342. line,
  2343. col;
  2344. tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
  2345. line = tokenStream.token().startLine;
  2346. col = tokenStream.token().startCol;
  2347. this._readWhitespace();
  2348. this.fire({
  2349. type: "startfontface",
  2350. line: line,
  2351. col: col
  2352. });
  2353. this._readDeclarations(true);
  2354. this.fire({
  2355. type: "endfontface",
  2356. line: line,
  2357. col: col
  2358. });
  2359. },
  2360. _viewport: function() {
  2361. var tokenStream = this._tokenStream,
  2362. line,
  2363. col;
  2364. tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
  2365. line = tokenStream.token().startLine;
  2366. col = tokenStream.token().startCol;
  2367. this._readWhitespace();
  2368. this.fire({
  2369. type: "startviewport",
  2370. line: line,
  2371. col: col
  2372. });
  2373. this._readDeclarations(true);
  2374. this.fire({
  2375. type: "endviewport",
  2376. line: line,
  2377. col: col
  2378. });
  2379. },
  2380. _document: function() {
  2381. var tokenStream = this._tokenStream,
  2382. token,
  2383. functions = [],
  2384. prefix = "";
  2385. tokenStream.mustMatch(Tokens.DOCUMENT_SYM);
  2386. token = tokenStream.token();
  2387. if (/^@-([^-]+)-/.test(token.value)) {
  2388. prefix = RegExp.$1;
  2389. }
  2390. this._readWhitespace();
  2391. functions.push(this._document_function());
  2392. while (tokenStream.match(Tokens.COMMA)) {
  2393. this._readWhitespace();
  2394. functions.push(this._document_function());
  2395. }
  2396. tokenStream.mustMatch(Tokens.LBRACE);
  2397. this._readWhitespace();
  2398. this.fire({
  2399. type: "startdocument",
  2400. functions: functions,
  2401. prefix: prefix,
  2402. line: token.startLine,
  2403. col: token.startCol
  2404. });
  2405. var ok = true;
  2406. while (ok) {
  2407. switch (tokenStream.peek()) {
  2408. case Tokens.PAGE_SYM:
  2409. this._page();
  2410. break;
  2411. case Tokens.FONT_FACE_SYM:
  2412. this._font_face();
  2413. break;
  2414. case Tokens.VIEWPORT_SYM:
  2415. this._viewport();
  2416. break;
  2417. case Tokens.MEDIA_SYM:
  2418. this._media();
  2419. break;
  2420. case Tokens.KEYFRAMES_SYM:
  2421. this._keyframes();
  2422. break;
  2423. case Tokens.DOCUMENT_SYM:
  2424. this._document();
  2425. break;
  2426. default:
  2427. ok = Boolean(this._ruleset());
  2428. }
  2429. }
  2430. tokenStream.mustMatch(Tokens.RBRACE);
  2431. token = tokenStream.token();
  2432. this._readWhitespace();
  2433. this.fire({
  2434. type: "enddocument",
  2435. functions: functions,
  2436. prefix: prefix,
  2437. line: token.startLine,
  2438. col: token.startCol
  2439. });
  2440. },
  2441. _document_function: function() {
  2442. var tokenStream = this._tokenStream,
  2443. value;
  2444. if (tokenStream.match(Tokens.URI)) {
  2445. value = tokenStream.token().value;
  2446. this._readWhitespace();
  2447. } else {
  2448. value = this._function();
  2449. }
  2450. return value;
  2451. },
  2452. _operator: function(inFunction) {
  2453. var tokenStream = this._tokenStream,
  2454. token = null;
  2455. if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
  2456. inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS])) {
  2457. token = tokenStream.token();
  2458. this._readWhitespace();
  2459. }
  2460. return token ? PropertyValuePart.fromToken(token) : null;
  2461. },
  2462. _combinator: function() {
  2463. var tokenStream = this._tokenStream,
  2464. value = null,
  2465. token;
  2466. if (tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])) {
  2467. token = tokenStream.token();
  2468. value = new Combinator(token.value, token.startLine, token.startCol);
  2469. this._readWhitespace();
  2470. }
  2471. return value;
  2472. },
  2473. _unary_operator: function() {
  2474. var tokenStream = this._tokenStream;
  2475. if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])) {
  2476. return tokenStream.token().value;
  2477. } else {
  2478. return null;
  2479. }
  2480. },
  2481. _property: function() {
  2482. var tokenStream = this._tokenStream,
  2483. value = null,
  2484. hack = null,
  2485. propertyName = "",
  2486. token,
  2487. line,
  2488. col;
  2489. if (tokenStream.peek() === Tokens.STAR && this.options.starHack) {
  2490. tokenStream.get();
  2491. token = tokenStream.token();
  2492. hack = token.value;
  2493. line = token.startLine;
  2494. col = token.startCol;
  2495. }
  2496. if (tokenStream.peek() === Tokens.MINUS) {
  2497. tokenStream.get();
  2498. token = tokenStream.token();
  2499. propertyName = token.value;
  2500. line = token.startLine;
  2501. col = token.startCol;
  2502. }
  2503. if (tokenStream.match(Tokens.IDENT)) {
  2504. token = tokenStream.token();
  2505. propertyName += token.value;
  2506. if (propertyName.charAt(0) === "_" && this.options.underscoreHack) {
  2507. hack = "_";
  2508. propertyName = propertyName.substring(1);
  2509. }
  2510. value = new PropertyName(propertyName, hack, line || token.startLine, col || token.startCol);
  2511. this._readWhitespace();
  2512. } else {
  2513. var tt = tokenStream.peek();
  2514. if (tt !== Tokens.EOF && tt !== Tokens.RBRACE) {
  2515. this._unexpectedToken(tokenStream.LT(1));
  2516. }
  2517. }
  2518. return value;
  2519. },
  2520. _ruleset: function() {
  2521. var tokenStream = this._tokenStream,
  2522. tt,
  2523. selectors;
  2524. try {
  2525. selectors = this._selectors_group();
  2526. } catch (ex) {
  2527. if (ex instanceof SyntaxError && !this.options.strict) {
  2528. this.fire({
  2529. type: "error",
  2530. error: ex,
  2531. message: ex.message,
  2532. line: ex.line,
  2533. col: ex.col
  2534. });
  2535. tt = tokenStream.advance([Tokens.RBRACE]);
  2536. if (tt === Tokens.RBRACE) {
  2537. } else {
  2538. throw ex;
  2539. }
  2540. } else {
  2541. throw ex;
  2542. }
  2543. return true;
  2544. }
  2545. if (selectors) {
  2546. this.fire({
  2547. type: "startrule",
  2548. selectors: selectors,
  2549. line: selectors[0].line,
  2550. col: selectors[0].col
  2551. });
  2552. this._readDeclarations(true);
  2553. this.fire({
  2554. type: "endrule",
  2555. selectors: selectors,
  2556. line: selectors[0].line,
  2557. col: selectors[0].col
  2558. });
  2559. }
  2560. return selectors;
  2561. },
  2562. _selectors_group: function() {
  2563. var tokenStream = this._tokenStream,
  2564. selectors = [],
  2565. selector;
  2566. selector = this._selector();
  2567. if (selector !== null) {
  2568. selectors.push(selector);
  2569. while (tokenStream.match(Tokens.COMMA)) {
  2570. this._readWhitespace();
  2571. selector = this._selector();
  2572. if (selector !== null) {
  2573. selectors.push(selector);
  2574. } else {
  2575. this._unexpectedToken(tokenStream.LT(1));
  2576. }
  2577. }
  2578. }
  2579. return selectors.length ? selectors : null;
  2580. },
  2581. _selector: function() {
  2582. var tokenStream = this._tokenStream,
  2583. selector = [],
  2584. nextSelector = null,
  2585. combinator = null,
  2586. ws = null;
  2587. nextSelector = this._simple_selector_sequence();
  2588. if (nextSelector === null) {
  2589. return null;
  2590. }
  2591. selector.push(nextSelector);
  2592. do {
  2593. combinator = this._combinator();
  2594. if (combinator !== null) {
  2595. selector.push(combinator);
  2596. nextSelector = this._simple_selector_sequence();
  2597. if (nextSelector === null) {
  2598. this._unexpectedToken(tokenStream.LT(1));
  2599. } else {
  2600. selector.push(nextSelector);
  2601. }
  2602. } else {
  2603. if (this._readWhitespace()) {
  2604. ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
  2605. combinator = this._combinator();
  2606. nextSelector = this._simple_selector_sequence();
  2607. if (nextSelector === null) {
  2608. if (combinator !== null) {
  2609. this._unexpectedToken(tokenStream.LT(1));
  2610. }
  2611. } else {
  2612. if (combinator !== null) {
  2613. selector.push(combinator);
  2614. } else {
  2615. selector.push(ws);
  2616. }
  2617. selector.push(nextSelector);
  2618. }
  2619. } else {
  2620. break;
  2621. }
  2622. }
  2623. } while (true);
  2624. return new Selector(selector, selector[0].line, selector[0].col);
  2625. },
  2626. _simple_selector_sequence: function() {
  2627. var tokenStream = this._tokenStream,
  2628. elementName = null,
  2629. modifiers = [],
  2630. selectorText = "",
  2631. components = [
  2632. function() {
  2633. return tokenStream.match(Tokens.HASH) ?
  2634. new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
  2635. null;
  2636. },
  2637. this._class,
  2638. this._attrib,
  2639. this._pseudo,
  2640. this._negation
  2641. ],
  2642. i = 0,
  2643. len = components.length,
  2644. component = null,
  2645. line,
  2646. col;
  2647. line = tokenStream.LT(1).startLine;
  2648. col = tokenStream.LT(1).startCol;
  2649. elementName = this._type_selector();
  2650. if (!elementName) {
  2651. elementName = this._universal();
  2652. }
  2653. if (elementName !== null) {
  2654. selectorText += elementName;
  2655. }
  2656. while (true) {
  2657. if (tokenStream.peek() === Tokens.S) {
  2658. break;
  2659. }
  2660. while (i < len && component === null) {
  2661. component = components[i++].call(this);
  2662. }
  2663. if (component === null) {
  2664. if (selectorText === "") {
  2665. return null;
  2666. } else {
  2667. break;
  2668. }
  2669. } else {
  2670. i = 0;
  2671. modifiers.push(component);
  2672. selectorText += component.toString();
  2673. component = null;
  2674. }
  2675. }
  2676. return selectorText !== "" ?
  2677. new SelectorPart(elementName, modifiers, selectorText, line, col) :
  2678. null;
  2679. },
  2680. _type_selector: function() {
  2681. var tokenStream = this._tokenStream,
  2682. ns = this._namespace_prefix(),
  2683. elementName = this._element_name();
  2684. if (!elementName) {
  2685. if (ns) {
  2686. tokenStream.unget();
  2687. if (ns.length > 1) {
  2688. tokenStream.unget();
  2689. }
  2690. }
  2691. return null;
  2692. } else {
  2693. if (ns) {
  2694. elementName.text = ns + elementName.text;
  2695. elementName.col -= ns.length;
  2696. }
  2697. return elementName;
  2698. }
  2699. },
  2700. _class: function() {
  2701. var tokenStream = this._tokenStream,
  2702. token;
  2703. if (tokenStream.match(Tokens.DOT)) {
  2704. tokenStream.mustMatch(Tokens.IDENT);
  2705. token = tokenStream.token();
  2706. return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
  2707. } else {
  2708. return null;
  2709. }
  2710. },
  2711. _element_name: function() {
  2712. var tokenStream = this._tokenStream,
  2713. token;
  2714. if (tokenStream.match(Tokens.IDENT)) {
  2715. token = tokenStream.token();
  2716. return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
  2717. } else {
  2718. return null;
  2719. }
  2720. },
  2721. _namespace_prefix: function() {
  2722. var tokenStream = this._tokenStream,
  2723. value = "";
  2724. if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE) {
  2725. if (tokenStream.match([Tokens.IDENT, Tokens.STAR])) {
  2726. value += tokenStream.token().value;
  2727. }
  2728. tokenStream.mustMatch(Tokens.PIPE);
  2729. value += "|";
  2730. }
  2731. return value.length ? value : null;
  2732. },
  2733. _universal: function() {
  2734. var tokenStream = this._tokenStream,
  2735. value = "",
  2736. ns;
  2737. ns = this._namespace_prefix();
  2738. if (ns) {
  2739. value += ns;
  2740. }
  2741. if (tokenStream.match(Tokens.STAR)) {
  2742. value += "*";
  2743. }
  2744. return value.length ? value : null;
  2745. },
  2746. _attrib: function() {
  2747. var tokenStream = this._tokenStream,
  2748. value = null,
  2749. ns,
  2750. token;
  2751. if (tokenStream.match(Tokens.LBRACKET)) {
  2752. token = tokenStream.token();
  2753. value = token.value;
  2754. value += this._readWhitespace();
  2755. ns = this._namespace_prefix();
  2756. if (ns) {
  2757. value += ns;
  2758. }
  2759. tokenStream.mustMatch(Tokens.IDENT);
  2760. value += tokenStream.token().value;
  2761. value += this._readWhitespace();
  2762. if (tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
  2763. Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])) {
  2764. value += tokenStream.token().value;
  2765. value += this._readWhitespace();
  2766. tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
  2767. value += tokenStream.token().value;
  2768. value += this._readWhitespace();
  2769. }
  2770. tokenStream.mustMatch(Tokens.RBRACKET);
  2771. return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
  2772. } else {
  2773. return null;
  2774. }
  2775. },
  2776. _pseudo: function() {
  2777. var tokenStream = this._tokenStream,
  2778. pseudo = null,
  2779. colons = ":",
  2780. line,
  2781. col;
  2782. if (tokenStream.match(Tokens.COLON)) {
  2783. if (tokenStream.match(Tokens.COLON)) {
  2784. colons += ":";
  2785. }
  2786. if (tokenStream.match(Tokens.IDENT)) {
  2787. pseudo = tokenStream.token().value;
  2788. line = tokenStream.token().startLine;
  2789. col = tokenStream.token().startCol - colons.length;
  2790. } else if (tokenStream.peek() === Tokens.FUNCTION) {
  2791. line = tokenStream.LT(1).startLine;
  2792. col = tokenStream.LT(1).startCol - colons.length;
  2793. pseudo = this._functional_pseudo();
  2794. }
  2795. if (pseudo) {
  2796. pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
  2797. } else {
  2798. var startLine = tokenStream.LT(1).startLine,
  2799. startCol = tokenStream.LT(0).startCol;
  2800. throw new SyntaxError("Expected a `FUNCTION` or `IDENT` after colon at line " + startLine + ", col " + startCol + ".", startLine, startCol);
  2801. }
  2802. }
  2803. return pseudo;
  2804. },
  2805. _functional_pseudo: function() {
  2806. var tokenStream = this._tokenStream,
  2807. value = null;
  2808. if (tokenStream.match(Tokens.FUNCTION)) {
  2809. value = tokenStream.token().value;
  2810. value += this._readWhitespace();
  2811. value += this._expression();
  2812. tokenStream.mustMatch(Tokens.RPAREN);
  2813. value += ")";
  2814. }
  2815. return value;
  2816. },
  2817. _expression: function() {
  2818. var tokenStream = this._tokenStream,
  2819. value = "";
  2820. while (tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
  2821. Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
  2822. Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
  2823. Tokens.RESOLUTION, Tokens.SLASH])) {
  2824. value += tokenStream.token().value;
  2825. value += this._readWhitespace();
  2826. }
  2827. return value.length ? value : null;
  2828. },
  2829. _negation: function() {
  2830. var tokenStream = this._tokenStream,
  2831. line,
  2832. col,
  2833. value = "",
  2834. arg,
  2835. subpart = null;
  2836. if (tokenStream.match(Tokens.NOT)) {
  2837. value = tokenStream.token().value;
  2838. line = tokenStream.token().startLine;
  2839. col = tokenStream.token().startCol;
  2840. value += this._readWhitespace();
  2841. arg = this._negation_arg();
  2842. value += arg;
  2843. value += this._readWhitespace();
  2844. tokenStream.match(Tokens.RPAREN);
  2845. value += tokenStream.token().value;
  2846. subpart = new SelectorSubPart(value, "not", line, col);
  2847. subpart.args.push(arg);
  2848. }
  2849. return subpart;
  2850. },
  2851. _negation_arg: function() {
  2852. var tokenStream = this._tokenStream,
  2853. args = [
  2854. this._type_selector,
  2855. this._universal,
  2856. function() {
  2857. return tokenStream.match(Tokens.HASH) ?
  2858. new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
  2859. null;
  2860. },
  2861. this._class,
  2862. this._attrib,
  2863. this._pseudo
  2864. ],
  2865. arg = null,
  2866. i = 0,
  2867. len = args.length,
  2868. line,
  2869. col,
  2870. part;
  2871. line = tokenStream.LT(1).startLine;
  2872. col = tokenStream.LT(1).startCol;
  2873. while (i < len && arg === null) {
  2874. arg = args[i].call(this);
  2875. i++;
  2876. }
  2877. if (arg === null) {
  2878. this._unexpectedToken(tokenStream.LT(1));
  2879. }
  2880. if (arg.type === "elementName") {
  2881. part = new SelectorPart(arg, [], arg.toString(), line, col);
  2882. } else {
  2883. part = new SelectorPart(null, [arg], arg.toString(), line, col);
  2884. }
  2885. return part;
  2886. },
  2887. _declaration: function() {
  2888. var tokenStream = this._tokenStream,
  2889. property = null,
  2890. expr = null,
  2891. prio = null,
  2892. invalid = null,
  2893. propertyName = "";
  2894. property = this._property();
  2895. if (property !== null) {
  2896. tokenStream.mustMatch(Tokens.COLON);
  2897. this._readWhitespace();
  2898. expr = this._expr();
  2899. if (!expr || expr.length === 0) {
  2900. this._unexpectedToken(tokenStream.LT(1));
  2901. }
  2902. prio = this._prio();
  2903. propertyName = property.toString();
  2904. if (this.options.starHack && property.hack === "*" ||
  2905. this.options.underscoreHack && property.hack === "_") {
  2906. propertyName = property.text;
  2907. }
  2908. try {
  2909. this._validateProperty(propertyName, expr);
  2910. } catch (ex) {
  2911. invalid = ex;
  2912. }
  2913. this.fire({
  2914. type: "property",
  2915. property: property,
  2916. value: expr,
  2917. important: prio,
  2918. line: property.line,
  2919. col: property.col,
  2920. invalid: invalid
  2921. });
  2922. return true;
  2923. } else {
  2924. return false;
  2925. }
  2926. },
  2927. _prio: function() {
  2928. var tokenStream = this._tokenStream,
  2929. result = tokenStream.match(Tokens.IMPORTANT_SYM);
  2930. this._readWhitespace();
  2931. return result;
  2932. },
  2933. _expr: function(inFunction) {
  2934. var values = [],
  2935. value = null,
  2936. operator = null;
  2937. value = this._term(inFunction);
  2938. if (value !== null) {
  2939. values.push(value);
  2940. do {
  2941. operator = this._operator(inFunction);
  2942. if (operator) {
  2943. values.push(operator);
  2944. } /*else {
  2945. values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
  2946. valueParts = [];
  2947. }*/
  2948. value = this._term(inFunction);
  2949. if (value === null) {
  2950. break;
  2951. } else {
  2952. values.push(value);
  2953. }
  2954. } while (true);
  2955. }
  2956. return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
  2957. },
  2958. _term: function(inFunction) {
  2959. var tokenStream = this._tokenStream,
  2960. unary = null,
  2961. value = null,
  2962. endChar = null,
  2963. part = null,
  2964. token,
  2965. line,
  2966. col;
  2967. unary = this._unary_operator();
  2968. if (unary !== null) {
  2969. line = tokenStream.token().startLine;
  2970. col = tokenStream.token().startCol;
  2971. }
  2972. if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters) {
  2973. value = this._ie_function();
  2974. if (unary === null) {
  2975. line = tokenStream.token().startLine;
  2976. col = tokenStream.token().startCol;
  2977. }
  2978. } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])) {
  2979. token = tokenStream.token();
  2980. endChar = token.endChar;
  2981. value = token.value + this._expr(inFunction).text;
  2982. if (unary === null) {
  2983. line = tokenStream.token().startLine;
  2984. col = tokenStream.token().startCol;
  2985. }
  2986. tokenStream.mustMatch(Tokens.type(endChar));
  2987. value += endChar;
  2988. this._readWhitespace();
  2989. } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
  2990. Tokens.ANGLE, Tokens.TIME,
  2991. Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])) {
  2992. value = tokenStream.token().value;
  2993. if (unary === null) {
  2994. line = tokenStream.token().startLine;
  2995. col = tokenStream.token().startCol;
  2996. part = PropertyValuePart.fromToken(tokenStream.token());
  2997. }
  2998. this._readWhitespace();
  2999. } else {
  3000. token = this._hexcolor();
  3001. if (token === null) {
  3002. if (unary === null) {
  3003. line = tokenStream.LT(1).startLine;
  3004. col = tokenStream.LT(1).startCol;
  3005. }
  3006. if (value === null) {
  3007. if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters) {
  3008. value = this._ie_function();
  3009. } else {
  3010. value = this._function();
  3011. }
  3012. }
  3013. } else {
  3014. value = token.value;
  3015. if (unary === null) {
  3016. line = token.startLine;
  3017. col = token.startCol;
  3018. }
  3019. }
  3020. }
  3021. return part !== null ? part : value !== null ?
  3022. new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
  3023. null;
  3024. },
  3025. _function: function() {
  3026. var tokenStream = this._tokenStream,
  3027. functionText = null,
  3028. expr = null,
  3029. lt;
  3030. if (tokenStream.match(Tokens.FUNCTION)) {
  3031. functionText = tokenStream.token().value;
  3032. this._readWhitespace();
  3033. expr = this._expr(true);
  3034. functionText += expr;
  3035. if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) {
  3036. do {
  3037. if (this._readWhitespace()) {
  3038. functionText += tokenStream.token().value;
  3039. }
  3040. if (tokenStream.LA(0) === Tokens.COMMA) {
  3041. functionText += tokenStream.token().value;
  3042. }
  3043. tokenStream.match(Tokens.IDENT);
  3044. functionText += tokenStream.token().value;
  3045. tokenStream.match(Tokens.EQUALS);
  3046. functionText += tokenStream.token().value;
  3047. lt = tokenStream.peek();
  3048. while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
  3049. tokenStream.get();
  3050. functionText += tokenStream.token().value;
  3051. lt = tokenStream.peek();
  3052. }
  3053. } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
  3054. }
  3055. tokenStream.match(Tokens.RPAREN);
  3056. functionText += ")";
  3057. this._readWhitespace();
  3058. }
  3059. return functionText;
  3060. },
  3061. _ie_function: function() {
  3062. var tokenStream = this._tokenStream,
  3063. functionText = null,
  3064. lt;
  3065. if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) {
  3066. functionText = tokenStream.token().value;
  3067. do {
  3068. if (this._readWhitespace()) {
  3069. functionText += tokenStream.token().value;
  3070. }
  3071. if (tokenStream.LA(0) === Tokens.COMMA) {
  3072. functionText += tokenStream.token().value;
  3073. }
  3074. tokenStream.match(Tokens.IDENT);
  3075. functionText += tokenStream.token().value;
  3076. tokenStream.match(Tokens.EQUALS);
  3077. functionText += tokenStream.token().value;
  3078. lt = tokenStream.peek();
  3079. while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
  3080. tokenStream.get();
  3081. functionText += tokenStream.token().value;
  3082. lt = tokenStream.peek();
  3083. }
  3084. } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
  3085. tokenStream.match(Tokens.RPAREN);
  3086. functionText += ")";
  3087. this._readWhitespace();
  3088. }
  3089. return functionText;
  3090. },
  3091. _hexcolor: function() {
  3092. var tokenStream = this._tokenStream,
  3093. token = null,
  3094. color;
  3095. if (tokenStream.match(Tokens.HASH)) {
  3096. token = tokenStream.token();
  3097. color = token.value;
  3098. if (!/#[a-f0-9]{3,6}/i.test(color)) {
  3099. throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  3100. }
  3101. this._readWhitespace();
  3102. }
  3103. return token;
  3104. },
  3105. _keyframes: function() {
  3106. var tokenStream = this._tokenStream,
  3107. token,
  3108. tt,
  3109. name,
  3110. prefix = "";
  3111. tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
  3112. token = tokenStream.token();
  3113. if (/^@-([^-]+)-/.test(token.value)) {
  3114. prefix = RegExp.$1;
  3115. }
  3116. this._readWhitespace();
  3117. name = this._keyframe_name();
  3118. this._readWhitespace();
  3119. tokenStream.mustMatch(Tokens.LBRACE);
  3120. this.fire({
  3121. type: "startkeyframes",
  3122. name: name,
  3123. prefix: prefix,
  3124. line: token.startLine,
  3125. col: token.startCol
  3126. });
  3127. this._readWhitespace();
  3128. tt = tokenStream.peek();
  3129. while (tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
  3130. this._keyframe_rule();
  3131. this._readWhitespace();
  3132. tt = tokenStream.peek();
  3133. }
  3134. this.fire({
  3135. type: "endkeyframes",
  3136. name: name,
  3137. prefix: prefix,
  3138. line: token.startLine,
  3139. col: token.startCol
  3140. });
  3141. this._readWhitespace();
  3142. tokenStream.mustMatch(Tokens.RBRACE);
  3143. this._readWhitespace();
  3144. },
  3145. _keyframe_name: function() {
  3146. var tokenStream = this._tokenStream;
  3147. tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
  3148. return SyntaxUnit.fromToken(tokenStream.token());
  3149. },
  3150. _keyframe_rule: function() {
  3151. var keyList = this._key_list();
  3152. this.fire({
  3153. type: "startkeyframerule",
  3154. keys: keyList,
  3155. line: keyList[0].line,
  3156. col: keyList[0].col
  3157. });
  3158. this._readDeclarations(true);
  3159. this.fire({
  3160. type: "endkeyframerule",
  3161. keys: keyList,
  3162. line: keyList[0].line,
  3163. col: keyList[0].col
  3164. });
  3165. },
  3166. _key_list: function() {
  3167. var tokenStream = this._tokenStream,
  3168. keyList = [];
  3169. keyList.push(this._key());
  3170. this._readWhitespace();
  3171. while (tokenStream.match(Tokens.COMMA)) {
  3172. this._readWhitespace();
  3173. keyList.push(this._key());
  3174. this._readWhitespace();
  3175. }
  3176. return keyList;
  3177. },
  3178. _key: function() {
  3179. var tokenStream = this._tokenStream,
  3180. token;
  3181. if (tokenStream.match(Tokens.PERCENTAGE)) {
  3182. return SyntaxUnit.fromToken(tokenStream.token());
  3183. } else if (tokenStream.match(Tokens.IDENT)) {
  3184. token = tokenStream.token();
  3185. if (/from|to/i.test(token.value)) {
  3186. return SyntaxUnit.fromToken(token);
  3187. }
  3188. tokenStream.unget();
  3189. }
  3190. this._unexpectedToken(tokenStream.LT(1));
  3191. },
  3192. _skipCruft: function() {
  3193. while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) {
  3194. }
  3195. },
  3196. _readDeclarations: function(checkStart, readMargins) {
  3197. var tokenStream = this._tokenStream,
  3198. tt;
  3199. this._readWhitespace();
  3200. if (checkStart) {
  3201. tokenStream.mustMatch(Tokens.LBRACE);
  3202. }
  3203. this._readWhitespace();
  3204. try {
  3205. while (true) {
  3206. if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())) {
  3207. } else if (this._declaration()) {
  3208. if (!tokenStream.match(Tokens.SEMICOLON)) {
  3209. break;
  3210. }
  3211. } else {
  3212. break;
  3213. }
  3214. this._readWhitespace();
  3215. }
  3216. tokenStream.mustMatch(Tokens.RBRACE);
  3217. this._readWhitespace();
  3218. } catch (ex) {
  3219. if (ex instanceof SyntaxError && !this.options.strict) {
  3220. this.fire({
  3221. type: "error",
  3222. error: ex,
  3223. message: ex.message,
  3224. line: ex.line,
  3225. col: ex.col
  3226. });
  3227. tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
  3228. if (tt === Tokens.SEMICOLON) {
  3229. this._readDeclarations(false, readMargins);
  3230. } else if (tt !== Tokens.EOF && tt !== Tokens.RBRACE) {
  3231. throw ex;
  3232. }
  3233. } else {
  3234. throw ex;
  3235. }
  3236. }
  3237. },
  3238. _readWhitespace: function() {
  3239. var tokenStream = this._tokenStream,
  3240. ws = "";
  3241. while (tokenStream.match(Tokens.S)) {
  3242. ws += tokenStream.token().value;
  3243. }
  3244. return ws;
  3245. },
  3246. _unexpectedToken: function(token) {
  3247. throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  3248. },
  3249. _verifyEnd: function() {
  3250. if (this._tokenStream.LA(1) !== Tokens.EOF) {
  3251. this._unexpectedToken(this._tokenStream.LT(1));
  3252. }
  3253. },
  3254. _validateProperty: function(property, value) {
  3255. Validation.validate(property, value);
  3256. },
  3257. parse: function(input) {
  3258. this._tokenStream = new TokenStream(input, Tokens);
  3259. this._stylesheet();
  3260. },
  3261. parseStyleSheet: function(input) {
  3262. return this.parse(input);
  3263. },
  3264. parseMediaQuery: function(input) {
  3265. this._tokenStream = new TokenStream(input, Tokens);
  3266. var result = this._media_query();
  3267. this._verifyEnd();
  3268. return result;
  3269. },
  3270. parsePropertyValue: function(input) {
  3271. this._tokenStream = new TokenStream(input, Tokens);
  3272. this._readWhitespace();
  3273. var result = this._expr();
  3274. this._readWhitespace();
  3275. this._verifyEnd();
  3276. return result;
  3277. },
  3278. parseRule: function(input) {
  3279. this._tokenStream = new TokenStream(input, Tokens);
  3280. this._readWhitespace();
  3281. var result = this._ruleset();
  3282. this._readWhitespace();
  3283. this._verifyEnd();
  3284. return result;
  3285. },
  3286. parseSelector: function(input) {
  3287. this._tokenStream = new TokenStream(input, Tokens);
  3288. this._readWhitespace();
  3289. var result = this._selector();
  3290. this._readWhitespace();
  3291. this._verifyEnd();
  3292. return result;
  3293. },
  3294. parseStyleAttribute: function(input) {
  3295. input += "}"; // for error recovery in _readDeclarations()
  3296. this._tokenStream = new TokenStream(input, Tokens);
  3297. this._readDeclarations();
  3298. }
  3299. };
  3300. for (prop in additions) {
  3301. if (Object.prototype.hasOwnProperty.call(additions, prop)) {
  3302. proto[prop] = additions[prop];
  3303. }
  3304. }
  3305. return proto;
  3306. }();
  3307. },{"../util/EventTarget":23,"../util/SyntaxError":25,"../util/SyntaxUnit":26,"./Combinator":2,"./MediaFeature":4,"./MediaQuery":5,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./TokenStream":17,"./Tokens":18,"./Validation":19}],7:[function(require,module,exports){
  3308. "use strict";
  3309. var Properties = module.exports = {
  3310. __proto__: null,
  3311. "align-items" : "flex-start | flex-end | center | baseline | stretch",
  3312. "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
  3313. "align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
  3314. "all" : "initial | inherit | unset",
  3315. "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch",
  3316. "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
  3317. "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
  3318. "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
  3319. "alignment-baseline" : "auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3320. "animation" : 1,
  3321. "animation-delay" : "<time>#",
  3322. "animation-direction" : "<single-animation-direction>#",
  3323. "animation-duration" : "<time>#",
  3324. "animation-fill-mode" : "[ none | forwards | backwards | both ]#",
  3325. "animation-iteration-count" : "[ <number> | infinite ]#",
  3326. "animation-name" : "[ none | <single-animation-name> ]#",
  3327. "animation-play-state" : "[ running | paused ]#",
  3328. "animation-timing-function" : 1,
  3329. "-moz-animation-delay" : "<time>#",
  3330. "-moz-animation-direction" : "[ normal | alternate ]#",
  3331. "-moz-animation-duration" : "<time>#",
  3332. "-moz-animation-iteration-count" : "[ <number> | infinite ]#",
  3333. "-moz-animation-name" : "[ none | <single-animation-name> ]#",
  3334. "-moz-animation-play-state" : "[ running | paused ]#",
  3335. "-ms-animation-delay" : "<time>#",
  3336. "-ms-animation-direction" : "[ normal | alternate ]#",
  3337. "-ms-animation-duration" : "<time>#",
  3338. "-ms-animation-iteration-count" : "[ <number> | infinite ]#",
  3339. "-ms-animation-name" : "[ none | <single-animation-name> ]#",
  3340. "-ms-animation-play-state" : "[ running | paused ]#",
  3341. "-webkit-animation-delay" : "<time>#",
  3342. "-webkit-animation-direction" : "[ normal | alternate ]#",
  3343. "-webkit-animation-duration" : "<time>#",
  3344. "-webkit-animation-fill-mode" : "[ none | forwards | backwards | both ]#",
  3345. "-webkit-animation-iteration-count" : "[ <number> | infinite ]#",
  3346. "-webkit-animation-name" : "[ none | <single-animation-name> ]#",
  3347. "-webkit-animation-play-state" : "[ running | paused ]#",
  3348. "-o-animation-delay" : "<time>#",
  3349. "-o-animation-direction" : "[ normal | alternate ]#",
  3350. "-o-animation-duration" : "<time>#",
  3351. "-o-animation-iteration-count" : "[ <number> | infinite ]#",
  3352. "-o-animation-name" : "[ none | <single-animation-name> ]#",
  3353. "-o-animation-play-state" : "[ running | paused ]#",
  3354. "appearance" : "none | auto",
  3355. "-moz-appearance" : "none | button | button-arrow-down | button-arrow-next | button-arrow-previous | button-arrow-up | button-bevel | button-focus | caret | checkbox | checkbox-container | checkbox-label | checkmenuitem | dualbutton | groupbox | listbox | listitem | menuarrow | menubar | menucheckbox | menuimage | menuitem | menuitemtext | menulist | menulist-button | menulist-text | menulist-textfield | menupopup | menuradio | menuseparator | meterbar | meterchunk | progressbar | progressbar-vertical | progresschunk | progresschunk-vertical | radio | radio-container | radio-label | radiomenuitem | range | range-thumb | resizer | resizerpanel | scale-horizontal | scalethumbend | scalethumb-horizontal | scalethumbstart | scalethumbtick | scalethumb-vertical | scale-vertical | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | separator | sheet | spinner | spinner-downbutton | spinner-textfield | spinner-upbutton | splitter | statusbar | statusbarpanel | tab | tabpanel | tabpanels | tab-scroll-arrow-back | tab-scroll-arrow-forward | textfield | textfield-multiline | toolbar | toolbarbutton | toolbarbutton-dropdown | toolbargripper | toolbox | tooltip | treeheader | treeheadercell | treeheadersortarrow | treeitem | treeline | treetwisty | treetwistyopen | treeview | -moz-mac-unified-toolbar | -moz-win-borderless-glass | -moz-win-browsertabbar-toolbox | -moz-win-communicationstext | -moz-win-communications-toolbox | -moz-win-exclude-glass | -moz-win-glass | -moz-win-mediatext | -moz-win-media-toolbox | -moz-window-button-box | -moz-window-button-box-maximized | -moz-window-button-close | -moz-window-button-maximize | -moz-window-button-minimize | -moz-window-button-restore | -moz-window-frame-bottom | -moz-window-frame-left | -moz-window-frame-right | -moz-window-titlebar | -moz-window-titlebar-maximized",
  3356. "-ms-appearance" : "none | icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
  3357. "-webkit-appearance" : "none | button | button-bevel | caps-lock-indicator | caret | checkbox | default-button | listbox | listitem | media-fullscreen-button | media-mute-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | push-button | radio | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbargripper-horizontal | scrollbargripper-vertical | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical",
  3358. "-o-appearance" : "none | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
  3359. "azimuth" : "<azimuth>",
  3360. "backface-visibility" : "visible | hidden",
  3361. "background" : 1,
  3362. "background-attachment" : "<attachment>#",
  3363. "background-clip" : "<box>#",
  3364. "background-color" : "<color>",
  3365. "background-image" : "<bg-image>#",
  3366. "background-origin" : "<box>#",
  3367. "background-position" : "<bg-position>",
  3368. "background-repeat" : "<repeat-style>#",
  3369. "background-size" : "<bg-size>#",
  3370. "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
  3371. "behavior" : 1,
  3372. "binding" : 1,
  3373. "bleed" : "<length>",
  3374. "bookmark-label" : "<content> | <attr> | <string>",
  3375. "bookmark-level" : "none | <integer>",
  3376. "bookmark-state" : "open | closed",
  3377. "bookmark-target" : "none | <uri> | <attr>",
  3378. "border" : "<border-width> || <border-style> || <color>",
  3379. "border-bottom" : "<border-width> || <border-style> || <color>",
  3380. "border-bottom-color" : "<color>",
  3381. "border-bottom-left-radius" : "<x-one-radius>",
  3382. "border-bottom-right-radius" : "<x-one-radius>",
  3383. "border-bottom-style" : "<border-style>",
  3384. "border-bottom-width" : "<border-width>",
  3385. "border-collapse" : "collapse | separate",
  3386. "border-color" : "<color>{1,4}",
  3387. "border-image" : 1,
  3388. "border-image-outset" : "[ <length> | <number> ]{1,4}",
  3389. "border-image-repeat" : "[ stretch | repeat | round | space ]{1,2}",
  3390. "border-image-slice" : "<border-image-slice>",
  3391. "border-image-source" : "<image> | none",
  3392. "border-image-width" : "[ <length> | <percentage> | <number> | auto ]{1,4}",
  3393. "border-left" : "<border-width> || <border-style> || <color>",
  3394. "border-left-color" : "<color>",
  3395. "border-left-style" : "<border-style>",
  3396. "border-left-width" : "<border-width>",
  3397. "border-radius" : "<border-radius>",
  3398. "border-right" : "<border-width> || <border-style> || <color>",
  3399. "border-right-color" : "<color>",
  3400. "border-right-style" : "<border-style>",
  3401. "border-right-width" : "<border-width>",
  3402. "border-spacing" : "<length>{1,2}",
  3403. "border-style" : "<border-style>{1,4}",
  3404. "border-top" : "<border-width> || <border-style> || <color>",
  3405. "border-top-color" : "<color>",
  3406. "border-top-left-radius" : "<x-one-radius>",
  3407. "border-top-right-radius" : "<x-one-radius>",
  3408. "border-top-style" : "<border-style>",
  3409. "border-top-width" : "<border-width>",
  3410. "border-width" : "<border-width>{1,4}",
  3411. "bottom" : "<margin-width>",
  3412. "-moz-box-align" : "start | end | center | baseline | stretch",
  3413. "-moz-box-decoration-break" : "slice | clone",
  3414. "-moz-box-direction" : "normal | reverse",
  3415. "-moz-box-flex" : "<number>",
  3416. "-moz-box-flex-group" : "<integer>",
  3417. "-moz-box-lines" : "single | multiple",
  3418. "-moz-box-ordinal-group" : "<integer>",
  3419. "-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis",
  3420. "-moz-box-pack" : "start | end | center | justify",
  3421. "-o-box-decoration-break" : "slice | clone",
  3422. "-webkit-box-align" : "start | end | center | baseline | stretch",
  3423. "-webkit-box-decoration-break" : "slice | clone",
  3424. "-webkit-box-direction" : "normal | reverse",
  3425. "-webkit-box-flex" : "<number>",
  3426. "-webkit-box-flex-group" : "<integer>",
  3427. "-webkit-box-lines" : "single | multiple",
  3428. "-webkit-box-ordinal-group" : "<integer>",
  3429. "-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis",
  3430. "-webkit-box-pack" : "start | end | center | justify",
  3431. "box-decoration-break" : "slice | clone",
  3432. "box-shadow" : "<box-shadow>",
  3433. "box-sizing" : "content-box | border-box",
  3434. "break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
  3435. "break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
  3436. "break-inside" : "auto | avoid | avoid-page | avoid-column",
  3437. "caption-side" : "top | bottom",
  3438. "clear" : "none | right | left | both",
  3439. "clip" : "<shape> | auto",
  3440. "-webkit-clip-path" : "<clip-source> | <clip-path> | none",
  3441. "clip-path" : "<clip-source> | <clip-path> | none",
  3442. "clip-rule" : "nonzero | evenodd",
  3443. "color" : "<color>",
  3444. "color-interpolation" : "auto | sRGB | linearRGB",
  3445. "color-interpolation-filters" : "auto | sRGB | linearRGB",
  3446. "color-profile" : 1,
  3447. "color-rendering" : "auto | optimizeSpeed | optimizeQuality",
  3448. "column-count" : "<integer> | auto", // https ://www.w3.org/TR/css3-multicol/
  3449. "column-fill" : "auto | balance",
  3450. "column-gap" : "<length> | normal",
  3451. "column-rule" : "<border-width> || <border-style> || <color>",
  3452. "column-rule-color" : "<color>",
  3453. "column-rule-style" : "<border-style>",
  3454. "column-rule-width" : "<border-width>",
  3455. "column-span" : "none | all",
  3456. "column-width" : "<length> | auto",
  3457. "columns" : 1,
  3458. "content" : 1,
  3459. "counter-increment" : 1,
  3460. "counter-reset" : 1,
  3461. "crop" : "<shape> | auto",
  3462. "cue" : "cue-after | cue-before",
  3463. "cue-after" : 1,
  3464. "cue-before" : 1,
  3465. "cursor" : 1,
  3466. "direction" : "ltr | rtl",
  3467. "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
  3468. "dominant-baseline" : "auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge",
  3469. "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
  3470. "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3471. "drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
  3472. "drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3473. "drop-initial-size" : "auto | line | <length> | <percentage>",
  3474. "drop-initial-value" : "<integer>",
  3475. "elevation" : "<angle> | below | level | above | higher | lower",
  3476. "empty-cells" : "show | hide",
  3477. "enable-background" : 1,
  3478. "fill" : "<paint>",
  3479. "fill-opacity" : "<opacity-value>",
  3480. "fill-rule" : "nonzero | evenodd",
  3481. "filter" : "<filter-function-list> | none",
  3482. "fit" : "fill | hidden | meet | slice",
  3483. "fit-position" : 1,
  3484. "flex" : "<flex>",
  3485. "flex-basis" : "<width>",
  3486. "flex-direction" : "row | row-reverse | column | column-reverse",
  3487. "flex-flow" : "<flex-direction> || <flex-wrap>",
  3488. "flex-grow" : "<number>",
  3489. "flex-shrink" : "<number>",
  3490. "flex-wrap" : "nowrap | wrap | wrap-reverse",
  3491. "-webkit-flex" : "<flex>",
  3492. "-webkit-flex-basis" : "<width>",
  3493. "-webkit-flex-direction" : "row | row-reverse | column | column-reverse",
  3494. "-webkit-flex-flow" : "<flex-direction> || <flex-wrap>",
  3495. "-webkit-flex-grow" : "<number>",
  3496. "-webkit-flex-shrink" : "<number>",
  3497. "-webkit-flex-wrap" : "nowrap | wrap | wrap-reverse",
  3498. "-ms-flex" : "<flex>",
  3499. "-ms-flex-align" : "start | end | center | stretch | baseline",
  3500. "-ms-flex-direction" : "row | row-reverse | column | column-reverse",
  3501. "-ms-flex-order" : "<number>",
  3502. "-ms-flex-pack" : "start | end | center | justify | distribute",
  3503. "-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
  3504. "float" : "left | right | none",
  3505. "float-offset" : 1,
  3506. "flood-color" : 1,
  3507. "flood-opacity" : "<opacity-value>",
  3508. "font" : "<font-shorthand> | caption | icon | menu | message-box | small-caption | status-bar",
  3509. "font-family" : "<font-family>",
  3510. "font-feature-settings" : "<feature-tag-value> | normal",
  3511. "font-kerning" : "auto | normal | none",
  3512. "font-size" : "<font-size>",
  3513. "font-size-adjust" : "<number> | none",
  3514. "font-stretch" : "<font-stretch>",
  3515. "font-style" : "<font-style>",
  3516. "font-variant" : "<font-variant> | normal | none",
  3517. "font-variant-alternates" : "<font-variant-alternates> | normal",
  3518. "font-variant-caps" : "<font-variant-caps> | normal",
  3519. "font-variant-east-asian" : "<font-variant-east-asian> | normal",
  3520. "font-variant-ligatures" : "<font-variant-ligatures> | normal | none",
  3521. "font-variant-numeric" : "<font-variant-numeric> | normal",
  3522. "font-variant-position" : "normal | sub | super",
  3523. "font-weight" : "<font-weight>",
  3524. "gap" : "[ <length> | <percentage> ]{1,2}",
  3525. "glyph-orientation-horizontal" : "<glyph-angle>",
  3526. "glyph-orientation-vertical" : "auto | <glyph-angle>",
  3527. "grid" : 1,
  3528. "grid-area" : 1,
  3529. "grid-auto-columns" : 1,
  3530. "grid-auto-flow" : 1,
  3531. "grid-auto-position" : 1,
  3532. "grid-auto-rows" : 1,
  3533. "grid-cell-stacking" : "columns | rows | layer",
  3534. "grid-column" : 1,
  3535. "grid-columns" : 1,
  3536. "grid-column-align" : "start | end | center | stretch",
  3537. "grid-column-sizing" : 1,
  3538. "grid-column-start" : 1,
  3539. "grid-column-end" : 1,
  3540. "grid-column-span" : "<integer>",
  3541. "grid-flow" : "none | rows | columns",
  3542. "grid-gap" : "[ <length> | <percentage> ]{1,2}",
  3543. "grid-layer" : "<integer>",
  3544. "grid-row" : 1,
  3545. "grid-rows" : 1,
  3546. "grid-row-align" : "start | end | center | stretch",
  3547. "grid-row-gap" : 1,
  3548. "grid-row-start" : 1,
  3549. "grid-row-end" : 1,
  3550. "grid-row-span" : "<integer>",
  3551. "grid-row-sizing" : 1,
  3552. "grid-template" : 1,
  3553. "grid-template-areas" : 1,
  3554. "grid-template-columns" : 1,
  3555. "grid-template-rows" : 1,
  3556. "hanging-punctuation" : 1,
  3557. "height" : "<margin-width> | <content-sizing>",
  3558. "hyphenate-after" : "<integer> | auto",
  3559. "hyphenate-before" : "<integer> | auto",
  3560. "hyphenate-character" : "<string> | auto",
  3561. "hyphenate-lines" : "no-limit | <integer>",
  3562. "hyphenate-resource" : 1,
  3563. "hyphens" : "none | manual | auto",
  3564. "icon" : 1,
  3565. "image-orientation" : "angle | auto",
  3566. "image-rendering" : "auto | optimizeSpeed | optimizeQuality",
  3567. "image-resolution" : 1,
  3568. "ime-mode" : "auto | normal | active | inactive | disabled",
  3569. "inline-box-align" : "last | <integer>",
  3570. "justify-content" : "flex-start | flex-end | center | space-between | space-around | space-evenly | stretch",
  3571. "-webkit-justify-content" : "flex-start | flex-end | center | space-between | space-around | space-evenly | stretch",
  3572. "kerning" : "auto | <length>",
  3573. "left" : "<margin-width>",
  3574. "letter-spacing" : "<length> | normal",
  3575. "line-height" : "<line-height>",
  3576. "line-break" : "auto | loose | normal | strict",
  3577. "line-stacking" : 1,
  3578. "line-stacking-ruby" : "exclude-ruby | include-ruby",
  3579. "line-stacking-shift" : "consider-shifts | disregard-shifts",
  3580. "line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
  3581. "list-style" : 1,
  3582. "list-style-image" : "<uri> | none",
  3583. "list-style-position" : "inside | outside",
  3584. "list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none",
  3585. "margin" : "<margin-width>{1,4}",
  3586. "margin-bottom" : "<margin-width>",
  3587. "margin-left" : "<margin-width>",
  3588. "margin-right" : "<margin-width>",
  3589. "margin-top" : "<margin-width>",
  3590. "mark" : 1,
  3591. "mark-after" : 1,
  3592. "mark-before" : 1,
  3593. "marker" : 1,
  3594. "marker-end" : 1,
  3595. "marker-mid" : 1,
  3596. "marker-start" : 1,
  3597. "marks" : 1,
  3598. "marquee-direction" : 1,
  3599. "marquee-play-count" : 1,
  3600. "marquee-speed" : 1,
  3601. "marquee-style" : 1,
  3602. "mask" : 1,
  3603. "max-height" : "<length> | <percentage> | <content-sizing> | none",
  3604. "max-width" : "<length> | <percentage> | <content-sizing> | none",
  3605. "min-height" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
  3606. "min-width" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
  3607. "mix-blend-mode" : "<blend-mode>",
  3608. "move-to" : 1,
  3609. "nav-down" : 1,
  3610. "nav-index" : 1,
  3611. "nav-left" : 1,
  3612. "nav-right" : 1,
  3613. "nav-up" : 1,
  3614. "object-fit" : "fill | contain | cover | none | scale-down",
  3615. "object-position" : "<position>",
  3616. "opacity" : "<opacity-value>",
  3617. "order" : "<integer>",
  3618. "-webkit-order" : "<integer>",
  3619. "orphans" : "<integer>",
  3620. "outline" : 1,
  3621. "outline-color" : "<color> | invert",
  3622. "outline-offset" : 1,
  3623. "outline-style" : "<border-style>",
  3624. "outline-width" : "<border-width>",
  3625. "overflow" : "visible | hidden | scroll | auto",
  3626. "overflow-style" : 1,
  3627. "overflow-wrap" : "normal | break-word",
  3628. "overflow-x" : 1,
  3629. "overflow-y" : 1,
  3630. "padding" : "<padding-width>{1,4}",
  3631. "padding-bottom" : "<padding-width>",
  3632. "padding-left" : "<padding-width>",
  3633. "padding-right" : "<padding-width>",
  3634. "padding-top" : "<padding-width>",
  3635. "page" : 1,
  3636. "page-break-after" : "auto | always | avoid | left | right",
  3637. "page-break-before" : "auto | always | avoid | left | right",
  3638. "page-break-inside" : "auto | avoid",
  3639. "page-policy" : 1,
  3640. "pause" : 1,
  3641. "pause-after" : 1,
  3642. "pause-before" : 1,
  3643. "perspective" : 1,
  3644. "perspective-origin" : 1,
  3645. "phonemes" : 1,
  3646. "pitch" : 1,
  3647. "pitch-range" : 1,
  3648. "play-during" : 1,
  3649. "pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all",
  3650. "position" : "static | relative | absolute | fixed | sticky | -webkit-sticky",
  3651. "presentation-level" : 1,
  3652. "punctuation-trim" : 1,
  3653. "quotes" : 1,
  3654. "rendering-intent" : 1,
  3655. "resize" : 1,
  3656. "rest" : 1,
  3657. "rest-after" : 1,
  3658. "rest-before" : 1,
  3659. "richness" : 1,
  3660. "right" : "<margin-width>",
  3661. "rotation" : 1,
  3662. "rotation-point" : 1,
  3663. "ruby-align" : 1,
  3664. "ruby-overhang" : 1,
  3665. "ruby-position" : 1,
  3666. "ruby-span" : 1,
  3667. "shape-rendering" : "auto | optimizeSpeed | crispEdges | geometricPrecision",
  3668. "size" : 1,
  3669. "speak" : "normal | none | spell-out",
  3670. "speak-header" : "once | always",
  3671. "speak-numeral" : "digits | continuous",
  3672. "speak-punctuation" : "code | none",
  3673. "speech-rate" : 1,
  3674. "src" : 1,
  3675. "stop-color" : 1,
  3676. "stop-opacity" : "<opacity-value>",
  3677. "stress" : 1,
  3678. "string-set" : 1,
  3679. "stroke" : "<paint>",
  3680. "stroke-dasharray" : "none | <dasharray>",
  3681. "stroke-dashoffset" : "<percentage> | <length>",
  3682. "stroke-linecap" : "butt | round | square",
  3683. "stroke-linejoin" : "miter | round | bevel",
  3684. "stroke-miterlimit" : "<miterlimit>",
  3685. "stroke-opacity" : "<opacity-value>",
  3686. "stroke-width" : "<percentage> | <length>",
  3687. "table-layout" : "auto | fixed",
  3688. "tab-size" : "<integer> | <length>",
  3689. "target" : 1,
  3690. "target-name" : 1,
  3691. "target-new" : 1,
  3692. "target-position" : 1,
  3693. "text-align" : "left | right | center | justify | match-parent | start | end",
  3694. "text-align-last" : 1,
  3695. "text-anchor" : "start | middle | end",
  3696. "text-decoration" : "<text-decoration-line> || <text-decoration-style> || <text-decoration-color>",
  3697. "text-decoration-color" : "<text-decoration-color>",
  3698. "text-decoration-line" : "<text-decoration-line>",
  3699. "text-decoration-style" : "<text-decoration-style>",
  3700. "text-decoration-skip" : "none | [ objects || spaces || ink || edges || box-decoration ]",
  3701. "-webkit-text-decoration-skip" : "none | [ objects || spaces || ink || edges || box-decoration ]",
  3702. "text-underline-position" : "auto | [ under || [ left | right ] ]",
  3703. "text-emphasis" : 1,
  3704. "text-height" : 1,
  3705. "text-indent" : "<length> | <percentage>",
  3706. "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
  3707. "text-outline" : 1,
  3708. "text-overflow" : 1,
  3709. "text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision",
  3710. "text-shadow" : 1,
  3711. "text-transform" : "capitalize | uppercase | lowercase | none",
  3712. "text-wrap" : "normal | none | avoid",
  3713. "top" : "<margin-width>",
  3714. "-ms-touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
  3715. "touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
  3716. "transform" : 1,
  3717. "transform-origin" : 1,
  3718. "transform-style" : 1,
  3719. "transition" : 1,
  3720. "transition-delay" : 1,
  3721. "transition-duration" : 1,
  3722. "transition-property" : 1,
  3723. "transition-timing-function" : 1,
  3724. "unicode-bidi" : "normal | embed | isolate | bidi-override | isolate-override | plaintext",
  3725. "user-modify" : "read-only | read-write | write-only",
  3726. "user-select" : "auto | text | none | contain | all",
  3727. "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",
  3728. "visibility" : "visible | hidden | collapse",
  3729. "voice-balance" : 1,
  3730. "voice-duration" : 1,
  3731. "voice-family" : 1,
  3732. "voice-pitch" : 1,
  3733. "voice-pitch-range" : 1,
  3734. "voice-rate" : 1,
  3735. "voice-stress" : 1,
  3736. "voice-volume" : 1,
  3737. "volume" : 1,
  3738. "white-space" : "normal | pre | nowrap | pre-wrap | pre-line | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", // https ://perishablepress.com/wrapping-content/
  3739. "white-space-collapse" : 1,
  3740. "widows" : "<integer>",
  3741. "width" : "<length> | <percentage> | <content-sizing> | auto",
  3742. "will-change" : "<will-change>",
  3743. "word-break" : "normal | keep-all | break-all | break-word",
  3744. "word-spacing" : "<length> | normal",
  3745. "word-wrap" : "normal | break-word",
  3746. "writing-mode" : "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb",
  3747. "z-index" : "<integer> | auto",
  3748. "zoom" : "<number> | <percentage> | normal"
  3749. };
  3750. },{}],8:[function(require,module,exports){
  3751. "use strict";
  3752. module.exports = PropertyName;
  3753. var SyntaxUnit = require("../util/SyntaxUnit");
  3754. var Parser = require("./Parser");
  3755. function PropertyName(text, hack, line, col) {
  3756. SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
  3757. this.hack = hack;
  3758. }
  3759. PropertyName.prototype = new SyntaxUnit();
  3760. PropertyName.prototype.constructor = PropertyName;
  3761. PropertyName.prototype.toString = function() {
  3762. return (this.hack ? this.hack : "") + this.text;
  3763. };
  3764. },{"../util/SyntaxUnit":26,"./Parser":6}],9:[function(require,module,exports){
  3765. "use strict";
  3766. module.exports = PropertyValue;
  3767. var SyntaxUnit = require("../util/SyntaxUnit");
  3768. var Parser = require("./Parser");
  3769. function PropertyValue(parts, line, col) {
  3770. SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
  3771. this.parts = parts;
  3772. }
  3773. PropertyValue.prototype = new SyntaxUnit();
  3774. PropertyValue.prototype.constructor = PropertyValue;
  3775. },{"../util/SyntaxUnit":26,"./Parser":6}],10:[function(require,module,exports){
  3776. "use strict";
  3777. module.exports = PropertyValueIterator;
  3778. function PropertyValueIterator(value) {
  3779. this._i = 0;
  3780. this._parts = value.parts;
  3781. this._marks = [];
  3782. this.value = value;
  3783. }
  3784. PropertyValueIterator.prototype.count = function() {
  3785. return this._parts.length;
  3786. };
  3787. PropertyValueIterator.prototype.isFirst = function() {
  3788. return this._i === 0;
  3789. };
  3790. PropertyValueIterator.prototype.hasNext = function() {
  3791. return this._i < this._parts.length;
  3792. };
  3793. PropertyValueIterator.prototype.mark = function() {
  3794. this._marks.push(this._i);
  3795. };
  3796. PropertyValueIterator.prototype.peek = function(count) {
  3797. return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
  3798. };
  3799. PropertyValueIterator.prototype.next = function() {
  3800. return this.hasNext() ? this._parts[this._i++] : null;
  3801. };
  3802. PropertyValueIterator.prototype.previous = function() {
  3803. return this._i > 0 ? this._parts[--this._i] : null;
  3804. };
  3805. PropertyValueIterator.prototype.restore = function() {
  3806. if (this._marks.length) {
  3807. this._i = this._marks.pop();
  3808. }
  3809. };
  3810. PropertyValueIterator.prototype.drop = function() {
  3811. this._marks.pop();
  3812. };
  3813. },{}],11:[function(require,module,exports){
  3814. "use strict";
  3815. module.exports = PropertyValuePart;
  3816. var SyntaxUnit = require("../util/SyntaxUnit");
  3817. var Colors = require("./Colors");
  3818. var Parser = require("./Parser");
  3819. var Tokens = require("./Tokens");
  3820. function PropertyValuePart(text, line, col, optionalHint) {
  3821. var hint = optionalHint || {};
  3822. SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
  3823. this.type = "unknown";
  3824. var temp;
  3825. if (/^([+-]?[\d.]+)([a-z]+)$/i.test(text)) { // dimension
  3826. this.type = "dimension";
  3827. this.value = Number(RegExp.$1);
  3828. this.units = RegExp.$2;
  3829. switch (this.units.toLowerCase()) {
  3830. case "em":
  3831. case "rem":
  3832. case "ex":
  3833. case "px":
  3834. case "cm":
  3835. case "mm":
  3836. case "in":
  3837. case "pt":
  3838. case "pc":
  3839. case "ch":
  3840. case "vh":
  3841. case "vw":
  3842. case "vmax":
  3843. case "vmin":
  3844. this.type = "length";
  3845. break;
  3846. case "fr":
  3847. this.type = "grid";
  3848. break;
  3849. case "deg":
  3850. case "rad":
  3851. case "grad":
  3852. case "turn":
  3853. this.type = "angle";
  3854. break;
  3855. case "ms":
  3856. case "s":
  3857. this.type = "time";
  3858. break;
  3859. case "hz":
  3860. case "khz":
  3861. this.type = "frequency";
  3862. break;
  3863. case "dpi":
  3864. case "dpcm":
  3865. this.type = "resolution";
  3866. break;
  3867. }
  3868. } else if (/^([+-]?[\d.]+)%$/i.test(text)) { // percentage
  3869. this.type = "percentage";
  3870. this.value = Number(RegExp.$1);
  3871. } else if (/^([+-]?\d+)$/i.test(text)) { // integer
  3872. this.type = "integer";
  3873. this.value = Number(RegExp.$1);
  3874. } else if (/^([+-]?[\d.]+)$/i.test(text)) { // number
  3875. this.type = "number";
  3876. this.value = Number(RegExp.$1);
  3877. } else if (/^#([a-f0-9]{3,6})/i.test(text)) { // hexcolor
  3878. this.type = "color";
  3879. temp = RegExp.$1;
  3880. if (temp.length === 3) {
  3881. this.red = parseInt(temp.charAt(0) + temp.charAt(0), 16);
  3882. this.green = parseInt(temp.charAt(1) + temp.charAt(1), 16);
  3883. this.blue = parseInt(temp.charAt(2) + temp.charAt(2), 16);
  3884. } else {
  3885. this.red = parseInt(temp.substring(0, 2), 16);
  3886. this.green = parseInt(temp.substring(2, 4), 16);
  3887. this.blue = parseInt(temp.substring(4, 6), 16);
  3888. }
  3889. } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)) { // rgb() color with absolute numbers
  3890. this.type = "color";
  3891. this.red = Number(RegExp.$1);
  3892. this.green = Number(RegExp.$2);
  3893. this.blue = Number(RegExp.$3);
  3894. } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { // rgb() color with percentages
  3895. this.type = "color";
  3896. this.red = Number(RegExp.$1) * 255 / 100;
  3897. this.green = Number(RegExp.$2) * 255 / 100;
  3898. this.blue = Number(RegExp.$3) * 255 / 100;
  3899. } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/i.test(text)) { // rgba() color with absolute numbers
  3900. this.type = "color";
  3901. this.red = Number(RegExp.$1);
  3902. this.green = Number(RegExp.$2);
  3903. this.blue = Number(RegExp.$3);
  3904. this.alpha = Number(RegExp.$4);
  3905. } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d.]+)\s*\)/i.test(text)) { // rgba() color with percentages
  3906. this.type = "color";
  3907. this.red = Number(RegExp.$1) * 255 / 100;
  3908. this.green = Number(RegExp.$2) * 255 / 100;
  3909. this.blue = Number(RegExp.$3) * 255 / 100;
  3910. this.alpha = Number(RegExp.$4);
  3911. } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { // hsl()
  3912. this.type = "color";
  3913. this.hue = Number(RegExp.$1);
  3914. this.saturation = Number(RegExp.$2) / 100;
  3915. this.lightness = Number(RegExp.$3) / 100;
  3916. } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d.]+)\s*\)/i.test(text)) { // hsla() color with percentages
  3917. this.type = "color";
  3918. this.hue = Number(RegExp.$1);
  3919. this.saturation = Number(RegExp.$2) / 100;
  3920. this.lightness = Number(RegExp.$3) / 100;
  3921. this.alpha = Number(RegExp.$4);
  3922. } else if (/^url\(("([^\\"]|\.)*")\)/i.test(text)) { // URI
  3923. this.type = "uri";
  3924. this.uri = PropertyValuePart.parseString(RegExp.$1);
  3925. } else if (/^([^(]+)\(/i.test(text)) {
  3926. this.type = "function";
  3927. this.name = RegExp.$1;
  3928. this.value = text;
  3929. } else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)) { // double-quoted string
  3930. this.type = "string";
  3931. this.value = PropertyValuePart.parseString(text);
  3932. } else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)) { // single-quoted string
  3933. this.type = "string";
  3934. this.value = PropertyValuePart.parseString(text);
  3935. } else if (Colors[text.toLowerCase()]) { // named color
  3936. this.type = "color";
  3937. temp = Colors[text.toLowerCase()].substring(1);
  3938. this.red = parseInt(temp.substring(0, 2), 16);
  3939. this.green = parseInt(temp.substring(2, 4), 16);
  3940. this.blue = parseInt(temp.substring(4, 6), 16);
  3941. } else if (/^[,/]$/.test(text)) {
  3942. this.type = "operator";
  3943. this.value = text;
  3944. } else if (/^-?[a-z_\u00A0-\uFFFF][a-z0-9\-_\u00A0-\uFFFF]*$/i.test(text)) {
  3945. this.type = "identifier";
  3946. this.value = text;
  3947. }
  3948. this.wasIdent = Boolean(hint.ident);
  3949. }
  3950. PropertyValuePart.prototype = new SyntaxUnit();
  3951. PropertyValuePart.prototype.constructor = PropertyValuePart;
  3952. PropertyValuePart.parseString = function(str) {
  3953. str = str.slice(1, -1); // Strip surrounding single/double quotes
  3954. var replacer = function(match, esc) {
  3955. if (/^(\n|\r\n|\r|\f)$/.test(esc)) {
  3956. return "";
  3957. }
  3958. var m = /^[0-9a-f]{1,6}/i.exec(esc);
  3959. if (m) {
  3960. var codePoint = parseInt(m[0], 16);
  3961. if (String.fromCodePoint) {
  3962. return String.fromCodePoint(codePoint);
  3963. } else {
  3964. return String.fromCharCode(codePoint);
  3965. }
  3966. }
  3967. return esc;
  3968. };
  3969. return str.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
  3970. replacer);
  3971. };
  3972. PropertyValuePart.serializeString = function(value) {
  3973. var replacer = function(match, c) {
  3974. if (c === "\"") {
  3975. return "\\" + c;
  3976. }
  3977. var cp = String.codePointAt ? String.codePointAt(0) :
  3978. String.charCodeAt(0);
  3979. return "\\" + cp.toString(16) + " ";
  3980. };
  3981. return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
  3982. };
  3983. PropertyValuePart.fromToken = function(token) {
  3984. var part = new PropertyValuePart(token.value, token.startLine, token.startCol, {
  3985. ident: token.type === Tokens.IDENT
  3986. });
  3987. return part;
  3988. };
  3989. },{"../util/SyntaxUnit":26,"./Colors":1,"./Parser":6,"./Tokens":18}],12:[function(require,module,exports){
  3990. "use strict";
  3991. var Pseudos = module.exports = {
  3992. __proto__: null,
  3993. ":first-letter": 1,
  3994. ":first-line": 1,
  3995. ":before": 1,
  3996. ":after": 1
  3997. };
  3998. Pseudos.ELEMENT = 1;
  3999. Pseudos.CLASS = 2;
  4000. Pseudos.isElement = function(pseudo) {
  4001. return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
  4002. };
  4003. },{}],13:[function(require,module,exports){
  4004. "use strict";
  4005. module.exports = Selector;
  4006. var SyntaxUnit = require("../util/SyntaxUnit");
  4007. var Parser = require("./Parser");
  4008. var Specificity = require("./Specificity");
  4009. function Selector(parts, line, col) {
  4010. SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
  4011. this.parts = parts;
  4012. this.specificity = Specificity.calculate(this);
  4013. }
  4014. Selector.prototype = new SyntaxUnit();
  4015. Selector.prototype.constructor = Selector;
  4016. },{"../util/SyntaxUnit":26,"./Parser":6,"./Specificity":16}],14:[function(require,module,exports){
  4017. "use strict";
  4018. module.exports = SelectorPart;
  4019. var SyntaxUnit = require("../util/SyntaxUnit");
  4020. var Parser = require("./Parser");
  4021. function SelectorPart(elementName, modifiers, text, line, col) {
  4022. SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
  4023. this.elementName = elementName;
  4024. this.modifiers = modifiers;
  4025. }
  4026. SelectorPart.prototype = new SyntaxUnit();
  4027. SelectorPart.prototype.constructor = SelectorPart;
  4028. },{"../util/SyntaxUnit":26,"./Parser":6}],15:[function(require,module,exports){
  4029. "use strict";
  4030. module.exports = SelectorSubPart;
  4031. var SyntaxUnit = require("../util/SyntaxUnit");
  4032. var Parser = require("./Parser");
  4033. function SelectorSubPart(text, type, line, col) {
  4034. SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
  4035. this.type = type;
  4036. this.args = [];
  4037. }
  4038. SelectorSubPart.prototype = new SyntaxUnit();
  4039. SelectorSubPart.prototype.constructor = SelectorSubPart;
  4040. },{"../util/SyntaxUnit":26,"./Parser":6}],16:[function(require,module,exports){
  4041. "use strict";
  4042. module.exports = Specificity;
  4043. var Pseudos = require("./Pseudos");
  4044. var SelectorPart = require("./SelectorPart");
  4045. function Specificity(a, b, c, d) {
  4046. this.a = a;
  4047. this.b = b;
  4048. this.c = c;
  4049. this.d = d;
  4050. }
  4051. Specificity.prototype = {
  4052. constructor: Specificity,
  4053. compare: function(other) {
  4054. var comps = ["a", "b", "c", "d"],
  4055. i, len;
  4056. for (i = 0, len = comps.length; i < len; i++) {
  4057. if (this[comps[i]] < other[comps[i]]) {
  4058. return -1;
  4059. } else if (this[comps[i]] > other[comps[i]]) {
  4060. return 1;
  4061. }
  4062. }
  4063. return 0;
  4064. },
  4065. valueOf: function() {
  4066. return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
  4067. },
  4068. toString: function() {
  4069. return this.a + "," + this.b + "," + this.c + "," + this.d;
  4070. }
  4071. };
  4072. Specificity.calculate = function(selector) {
  4073. var i,
  4074. len,
  4075. part,
  4076. b = 0,
  4077. c = 0,
  4078. d = 0;
  4079. function updateValues(part) {
  4080. var i, j, len, num,
  4081. elementName = part.elementName ? part.elementName.text : "",
  4082. modifier;
  4083. if (elementName && elementName.charAt(elementName.length - 1) !== "*") {
  4084. d++;
  4085. }
  4086. for (i = 0, len = part.modifiers.length; i < len; i++) {
  4087. modifier = part.modifiers[i];
  4088. switch (modifier.type) {
  4089. case "class":
  4090. case "attribute":
  4091. c++;
  4092. break;
  4093. case "id":
  4094. b++;
  4095. break;
  4096. case "pseudo":
  4097. if (Pseudos.isElement(modifier.text)) {
  4098. d++;
  4099. } else {
  4100. c++;
  4101. }
  4102. break;
  4103. case "not":
  4104. for (j = 0, num = modifier.args.length; j < num; j++) {
  4105. updateValues(modifier.args[j]);
  4106. }
  4107. }
  4108. }
  4109. }
  4110. for (i = 0, len = selector.parts.length; i < len; i++) {
  4111. part = selector.parts[i];
  4112. if (part instanceof SelectorPart) {
  4113. updateValues(part);
  4114. }
  4115. }
  4116. return new Specificity(0, b, c, d);
  4117. };
  4118. },{"./Pseudos":12,"./SelectorPart":14}],17:[function(require,module,exports){
  4119. "use strict";
  4120. module.exports = TokenStream;
  4121. var TokenStreamBase = require("../util/TokenStreamBase");
  4122. var PropertyValuePart = require("./PropertyValuePart");
  4123. var Tokens = require("./Tokens");
  4124. var h = /^[0-9a-fA-F]$/,
  4125. nonascii = /^[\u00A0-\uFFFF]$/,
  4126. nl = /\n|\r\n|\r|\f/,
  4127. whitespace = /\u0009|\u000a|\u000c|\u000d|\u0020/;
  4128. function isHexDigit(c) {
  4129. return c != null && h.test(c);
  4130. }
  4131. function isDigit(c) {
  4132. return c != null && /\d/.test(c);
  4133. }
  4134. function isWhitespace(c) {
  4135. return c != null && whitespace.test(c);
  4136. }
  4137. function isNewLine(c) {
  4138. return c != null && nl.test(c);
  4139. }
  4140. function isNameStart(c) {
  4141. return c != null && /[a-z_\u00A0-\uFFFF\\]/i.test(c);
  4142. }
  4143. function isNameChar(c) {
  4144. return c != null && (isNameStart(c) || /[0-9\-\\]/.test(c));
  4145. }
  4146. function isIdentStart(c) {
  4147. return c != null && (isNameStart(c) || /-\\/.test(c));
  4148. }
  4149. function mix(receiver, supplier) {
  4150. for (var prop in supplier) {
  4151. if (Object.prototype.hasOwnProperty.call(supplier, prop)) {
  4152. receiver[prop] = supplier[prop];
  4153. }
  4154. }
  4155. return receiver;
  4156. }
  4157. function wouldStartIdent(twoCodePoints) {
  4158. return typeof twoCodePoints === "string" &&
  4159. (twoCodePoints[0] === "-" && isNameStart(twoCodePoints[1]) || isNameStart(twoCodePoints[0]));
  4160. }
  4161. function wouldStartUnsignedNumber(twoCodePoints) {
  4162. return typeof twoCodePoints === "string" &&
  4163. (isDigit(twoCodePoints[0]) || (twoCodePoints[0] === "." && isDigit(twoCodePoints[1])));
  4164. }
  4165. function TokenStream(input) {
  4166. TokenStreamBase.call(this, input, Tokens);
  4167. }
  4168. TokenStream.prototype = mix(new TokenStreamBase(), {
  4169. _getToken: function() {
  4170. var c,
  4171. reader = this._reader,
  4172. token = null,
  4173. startLine = reader.getLine(),
  4174. startCol = reader.getCol();
  4175. c = reader.read();
  4176. while (c) {
  4177. switch (c) {
  4178. case "/":
  4179. if (reader.peek() === "*") {
  4180. token = this.commentToken(c, startLine, startCol);
  4181. } else {
  4182. token = this.charToken(c, startLine, startCol);
  4183. }
  4184. break;
  4185. case "|":
  4186. case "~":
  4187. case "^":
  4188. case "$":
  4189. case "*":
  4190. if (reader.peek() === "=") {
  4191. token = this.comparisonToken(c, startLine, startCol);
  4192. } else {
  4193. token = this.charToken(c, startLine, startCol);
  4194. }
  4195. break;
  4196. case "\"":
  4197. case "'":
  4198. token = this.stringToken(c, startLine, startCol);
  4199. break;
  4200. case "#":
  4201. if (isNameChar(reader.peek())) {
  4202. token = this.hashToken(c, startLine, startCol);
  4203. } else {
  4204. token = this.charToken(c, startLine, startCol);
  4205. }
  4206. break;
  4207. case ".":
  4208. if (isDigit(reader.peek())) {
  4209. token = this.numberToken(c, startLine, startCol);
  4210. } else {
  4211. token = this.charToken(c, startLine, startCol);
  4212. }
  4213. break;
  4214. case "-":
  4215. if (wouldStartUnsignedNumber(reader.peekCount(2))) {
  4216. token = this.numberToken(c, startLine, startCol);
  4217. break;
  4218. } else if (reader.peekCount(2) === "->") {
  4219. token = this.htmlCommentEndToken(c, startLine, startCol);
  4220. } else {
  4221. token = this._getDefaultToken(c, startLine, startCol);
  4222. }
  4223. break;
  4224. case "+":
  4225. if (wouldStartUnsignedNumber(reader.peekCount(2))) {
  4226. token = this.numberToken(c, startLine, startCol);
  4227. } else {
  4228. token = this.charToken(c, startLine, startCol);
  4229. }
  4230. break;
  4231. case "!":
  4232. token = this.importantToken(c, startLine, startCol);
  4233. break;
  4234. case "@":
  4235. token = this.atRuleToken(c, startLine, startCol);
  4236. break;
  4237. case ":":
  4238. token = this.notToken(c, startLine, startCol);
  4239. break;
  4240. case "<":
  4241. token = this.htmlCommentStartToken(c, startLine, startCol);
  4242. break;
  4243. case "\\":
  4244. if (/[^\r\n\f]/.test(reader.peek())) {
  4245. token = this.identOrFunctionToken(this.readEscape(c, true), startLine, startCol);
  4246. } else {
  4247. token = this.charToken(c, startLine, startCol);
  4248. }
  4249. break;
  4250. case "U":
  4251. case "u":
  4252. if (reader.peek() === "+") {
  4253. token = this.unicodeRangeToken(c, startLine, startCol);
  4254. } else {
  4255. token = this._getDefaultToken(c, startLine, startCol);
  4256. }
  4257. break;
  4258. default:
  4259. token = this._getDefaultToken(c, startLine, startCol);
  4260. }
  4261. break;
  4262. }
  4263. if (!token && c === null) {
  4264. token = this.createToken(Tokens.EOF, null, startLine, startCol);
  4265. }
  4266. return token;
  4267. },
  4268. _getDefaultToken: function(c, startLine, startCol) {
  4269. var reader = this._reader,
  4270. token = null;
  4271. if (isDigit(c)) {
  4272. token = this.numberToken(c, startLine, startCol);
  4273. } else
  4274. if (isWhitespace(c)) {
  4275. token = this.whitespaceToken(c, startLine, startCol);
  4276. } else
  4277. if (wouldStartIdent(c + reader.peekCount(1))) {
  4278. token = this.identOrFunctionToken(c, startLine, startCol);
  4279. } else {
  4280. token = this.charToken(c, startLine, startCol);
  4281. }
  4282. return token;
  4283. },
  4284. createToken: function(tt, value, startLine, startCol, options) {
  4285. var reader = this._reader;
  4286. options = options || {};
  4287. return {
  4288. value: value,
  4289. type: tt,
  4290. channel: options.channel,
  4291. endChar: options.endChar,
  4292. hide: options.hide || false,
  4293. startLine: startLine,
  4294. startCol: startCol,
  4295. endLine: reader.getLine(),
  4296. endCol: reader.getCol()
  4297. };
  4298. },
  4299. atRuleToken: function(first, startLine, startCol) {
  4300. var rule = first,
  4301. reader = this._reader,
  4302. tt = Tokens.CHAR,
  4303. ident;
  4304. reader.mark();
  4305. ident = this.readName();
  4306. rule = first + ident;
  4307. tt = Tokens.type(rule.toLowerCase());
  4308. if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN) {
  4309. if (rule.length > 1) {
  4310. tt = Tokens.UNKNOWN_SYM;
  4311. } else {
  4312. tt = Tokens.CHAR;
  4313. rule = first;
  4314. reader.reset();
  4315. }
  4316. }
  4317. return this.createToken(tt, rule, startLine, startCol);
  4318. },
  4319. charToken: function(c, startLine, startCol) {
  4320. var tt = Tokens.type(c);
  4321. var opts = {};
  4322. if (tt === -1) {
  4323. tt = Tokens.CHAR;
  4324. } else {
  4325. opts.endChar = Tokens[tt].endChar;
  4326. }
  4327. return this.createToken(tt, c, startLine, startCol, opts);
  4328. },
  4329. commentToken: function(first, startLine, startCol) {
  4330. var comment = this.readComment(first);
  4331. return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
  4332. },
  4333. comparisonToken: function(c, startLine, startCol) {
  4334. var reader = this._reader,
  4335. comparison = c + reader.read(),
  4336. tt = Tokens.type(comparison) || Tokens.CHAR;
  4337. return this.createToken(tt, comparison, startLine, startCol);
  4338. },
  4339. hashToken: function(first, startLine, startCol) {
  4340. var name = this.readName(first);
  4341. return this.createToken(Tokens.HASH, name, startLine, startCol);
  4342. },
  4343. htmlCommentStartToken: function(first, startLine, startCol) {
  4344. var reader = this._reader,
  4345. text = first;
  4346. reader.mark();
  4347. text += reader.readCount(3);
  4348. if (text === "<!--") {
  4349. return this.createToken(Tokens.CDO, text, startLine, startCol);
  4350. } else {
  4351. reader.reset();
  4352. return this.charToken(first, startLine, startCol);
  4353. }
  4354. },
  4355. htmlCommentEndToken: function(first, startLine, startCol) {
  4356. var reader = this._reader,
  4357. text = first;
  4358. reader.mark();
  4359. text += reader.readCount(2);
  4360. if (text === "-->") {
  4361. return this.createToken(Tokens.CDC, text, startLine, startCol);
  4362. } else {
  4363. reader.reset();
  4364. return this.charToken(first, startLine, startCol);
  4365. }
  4366. },
  4367. identOrFunctionToken: function(first, startLine, startCol) {
  4368. var reader = this._reader,
  4369. ident = this.readName(first),
  4370. tt = Tokens.IDENT,
  4371. uriFns = ["url(", "url-prefix(", "domain("],
  4372. uri;
  4373. if (reader.peek() === "(") {
  4374. ident += reader.read();
  4375. if (uriFns.indexOf(ident.toLowerCase()) > -1) {
  4376. reader.mark();
  4377. uri = this.readURI(ident);
  4378. if (uri === null) {
  4379. reader.reset();
  4380. tt = Tokens.FUNCTION;
  4381. } else {
  4382. tt = Tokens.URI;
  4383. ident = uri;
  4384. }
  4385. } else {
  4386. tt = Tokens.FUNCTION;
  4387. }
  4388. } else if (reader.peek() === ":") { // might be an IE function
  4389. if (ident.toLowerCase() === "progid") {
  4390. ident += reader.readTo("(");
  4391. tt = Tokens.IE_FUNCTION;
  4392. }
  4393. }
  4394. return this.createToken(tt, ident, startLine, startCol);
  4395. },
  4396. importantToken: function(first, startLine, startCol) {
  4397. var reader = this._reader,
  4398. important = first,
  4399. tt = Tokens.CHAR,
  4400. temp,
  4401. c;
  4402. reader.mark();
  4403. c = reader.read();
  4404. while (c) {
  4405. if (c === "/") {
  4406. if (reader.peek() !== "*") {
  4407. break;
  4408. } else {
  4409. temp = this.readComment(c);
  4410. if (temp === "") { // broken!
  4411. break;
  4412. }
  4413. }
  4414. } else if (isWhitespace(c)) {
  4415. important += c + this.readWhitespace();
  4416. } else if (/i/i.test(c)) {
  4417. temp = reader.readCount(8);
  4418. if (/mportant/i.test(temp)) {
  4419. important += c + temp;
  4420. tt = Tokens.IMPORTANT_SYM;
  4421. }
  4422. break; // we're done
  4423. } else {
  4424. break;
  4425. }
  4426. c = reader.read();
  4427. }
  4428. if (tt === Tokens.CHAR) {
  4429. reader.reset();
  4430. return this.charToken(first, startLine, startCol);
  4431. } else {
  4432. return this.createToken(tt, important, startLine, startCol);
  4433. }
  4434. },
  4435. notToken: function(first, startLine, startCol) {
  4436. var reader = this._reader,
  4437. text = first;
  4438. reader.mark();
  4439. text += reader.readCount(4);
  4440. if (text.toLowerCase() === ":not(") {
  4441. return this.createToken(Tokens.NOT, text, startLine, startCol);
  4442. } else {
  4443. reader.reset();
  4444. return this.charToken(first, startLine, startCol);
  4445. }
  4446. },
  4447. numberToken: function(first, startLine, startCol) {
  4448. var reader = this._reader,
  4449. value = this.readNumber(first),
  4450. ident,
  4451. tt = Tokens.NUMBER,
  4452. c = reader.peek();
  4453. if (isIdentStart(c)) {
  4454. ident = this.readName(reader.read());
  4455. value += ident;
  4456. if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^fr$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)) {
  4457. tt = Tokens.LENGTH;
  4458. } else if (/^deg|^rad$|^grad$|^turn$/i.test(ident)) {
  4459. tt = Tokens.ANGLE;
  4460. } else if (/^ms$|^s$/i.test(ident)) {
  4461. tt = Tokens.TIME;
  4462. } else if (/^hz$|^khz$/i.test(ident)) {
  4463. tt = Tokens.FREQ;
  4464. } else if (/^dpi$|^dpcm$/i.test(ident)) {
  4465. tt = Tokens.RESOLUTION;
  4466. } else {
  4467. tt = Tokens.DIMENSION;
  4468. }
  4469. } else if (c === "%") {
  4470. value += reader.read();
  4471. tt = Tokens.PERCENTAGE;
  4472. }
  4473. return this.createToken(tt, value, startLine, startCol);
  4474. },
  4475. stringToken: function(first, startLine, startCol) {
  4476. var delim = first,
  4477. string = first,
  4478. reader = this._reader,
  4479. tt = Tokens.STRING,
  4480. c = reader.read(),
  4481. i;
  4482. while (c) {
  4483. string += c;
  4484. if (c === "\\") {
  4485. c = reader.read();
  4486. if (c === null) {
  4487. break; // premature EOF after backslash
  4488. } else if (/[^\r\n\f0-9a-f]/i.test(c)) {
  4489. string += c;
  4490. } else {
  4491. for (i = 0; isHexDigit(c) && i < 6; i++) {
  4492. string += c;
  4493. c = reader.read();
  4494. }
  4495. if (c === "\r" && reader.peek() === "\n") {
  4496. string += c;
  4497. c = reader.read();
  4498. }
  4499. if (isWhitespace(c)) {
  4500. string += c;
  4501. } else {
  4502. continue;
  4503. }
  4504. }
  4505. } else if (c === delim) {
  4506. break; // delimiter found.
  4507. } else if (isNewLine(reader.peek())) {
  4508. tt = Tokens.INVALID;
  4509. break;
  4510. }
  4511. c = reader.read();
  4512. }
  4513. if (c === null) {
  4514. tt = Tokens.INVALID;
  4515. }
  4516. return this.createToken(tt, string, startLine, startCol);
  4517. },
  4518. unicodeRangeToken: function(first, startLine, startCol) {
  4519. var reader = this._reader,
  4520. value = first,
  4521. temp,
  4522. tt = Tokens.CHAR;
  4523. if (reader.peek() === "+") {
  4524. reader.mark();
  4525. value += reader.read();
  4526. value += this.readUnicodeRangePart(true);
  4527. if (value.length === 2) {
  4528. reader.reset();
  4529. } else {
  4530. tt = Tokens.UNICODE_RANGE;
  4531. if (value.indexOf("?") === -1) {
  4532. if (reader.peek() === "-") {
  4533. reader.mark();
  4534. temp = reader.read();
  4535. temp += this.readUnicodeRangePart(false);
  4536. if (temp.length === 1) {
  4537. reader.reset();
  4538. } else {
  4539. value += temp;
  4540. }
  4541. }
  4542. }
  4543. }
  4544. }
  4545. return this.createToken(tt, value, startLine, startCol);
  4546. },
  4547. whitespaceToken: function(first, startLine, startCol) {
  4548. var value = first + this.readWhitespace();
  4549. return this.createToken(Tokens.S, value, startLine, startCol);
  4550. },
  4551. readUnicodeRangePart: function(allowQuestionMark) {
  4552. var reader = this._reader,
  4553. part = "",
  4554. c = reader.peek();
  4555. while (isHexDigit(c) && part.length < 6) {
  4556. reader.read();
  4557. part += c;
  4558. c = reader.peek();
  4559. }
  4560. if (allowQuestionMark) {
  4561. while (c === "?" && part.length < 6) {
  4562. reader.read();
  4563. part += c;
  4564. c = reader.peek();
  4565. }
  4566. }
  4567. return part;
  4568. },
  4569. readWhitespace: function() {
  4570. var reader = this._reader,
  4571. whitespace = "",
  4572. c = reader.peek();
  4573. while (isWhitespace(c)) {
  4574. reader.read();
  4575. whitespace += c;
  4576. c = reader.peek();
  4577. }
  4578. return whitespace;
  4579. },
  4580. readNumber: function(first) {
  4581. var reader = this._reader,
  4582. number = first,
  4583. hasDot = first === ".",
  4584. c = reader.peek();
  4585. while (c) {
  4586. if (isDigit(c)) {
  4587. number += reader.read();
  4588. } else if (c === ".") {
  4589. if (hasDot) {
  4590. break;
  4591. } else {
  4592. hasDot = true;
  4593. number += reader.read();
  4594. }
  4595. } else {
  4596. break;
  4597. }
  4598. c = reader.peek();
  4599. }
  4600. return number;
  4601. },
  4602. readString: function() {
  4603. var token = this.stringToken(this._reader.read(), 0, 0);
  4604. return token.type === Tokens.INVALID ? null : token.value;
  4605. },
  4606. readURI: function(first) {
  4607. var reader = this._reader,
  4608. uri = first,
  4609. inner = "",
  4610. c = reader.peek();
  4611. while (c && isWhitespace(c)) {
  4612. reader.read();
  4613. c = reader.peek();
  4614. }
  4615. if (c === "'" || c === "\"") {
  4616. inner = this.readString();
  4617. if (inner !== null) {
  4618. inner = PropertyValuePart.parseString(inner);
  4619. }
  4620. } else {
  4621. inner = this.readUnquotedURL();
  4622. }
  4623. c = reader.peek();
  4624. while (c && isWhitespace(c)) {
  4625. reader.read();
  4626. c = reader.peek();
  4627. }
  4628. if (inner === null || c !== ")") {
  4629. uri = null;
  4630. } else {
  4631. uri += PropertyValuePart.serializeString(inner) + reader.read();
  4632. }
  4633. return uri;
  4634. },
  4635. readUnquotedURL: function(first) {
  4636. var reader = this._reader,
  4637. url = first || "",
  4638. c;
  4639. for (c = reader.peek(); c; c = reader.peek()) {
  4640. if (nonascii.test(c) || /^[-!#$%&*-[\]-~]$/.test(c)) {
  4641. url += c;
  4642. reader.read();
  4643. } else if (c === "\\") {
  4644. if (/^[^\r\n\f]$/.test(reader.peek(2))) {
  4645. url += this.readEscape(reader.read(), true);
  4646. } else {
  4647. break; // bad escape sequence.
  4648. }
  4649. } else {
  4650. break; // bad character
  4651. }
  4652. }
  4653. return url;
  4654. },
  4655. readName: function(first) {
  4656. var reader = this._reader,
  4657. ident = first || "",
  4658. c;
  4659. for (c = reader.peek(); c; c = reader.peek()) {
  4660. if (c === "\\") {
  4661. if (/^[^\r\n\f]$/.test(reader.peek(2))) {
  4662. ident += this.readEscape(reader.read(), true);
  4663. } else {
  4664. break;
  4665. }
  4666. } else if (isNameChar(c)) {
  4667. ident += reader.read();
  4668. } else {
  4669. break;
  4670. }
  4671. }
  4672. return ident;
  4673. },
  4674. readEscape: function(first, unescape) {
  4675. var reader = this._reader,
  4676. cssEscape = first || "",
  4677. i = 0,
  4678. c = reader.peek();
  4679. if (isHexDigit(c)) {
  4680. do {
  4681. cssEscape += reader.read();
  4682. c = reader.peek();
  4683. } while (c && isHexDigit(c) && ++i < 6);
  4684. }
  4685. if (cssEscape.length === 1) {
  4686. if (/^[^\r\n\f0-9a-f]$/.test(c)) {
  4687. reader.read();
  4688. if (unescape) {
  4689. return c;
  4690. }
  4691. } else {
  4692. throw new Error("Bad escape sequence.");
  4693. }
  4694. } else if (c === "\r") {
  4695. reader.read();
  4696. if (reader.peek() === "\n") {
  4697. c += reader.read();
  4698. }
  4699. } else if (/^[ \t\n\f]$/.test(c)) {
  4700. reader.read();
  4701. } else {
  4702. c = "";
  4703. }
  4704. if (unescape) {
  4705. var cp = parseInt(cssEscape.slice(first.length), 16);
  4706. return String.fromCodePoint ? String.fromCodePoint(cp) :
  4707. String.fromCharCode(cp);
  4708. }
  4709. return cssEscape + c;
  4710. },
  4711. readComment: function(first) {
  4712. var reader = this._reader,
  4713. comment = first || "",
  4714. c = reader.read();
  4715. if (c === "*") {
  4716. while (c) {
  4717. comment += c;
  4718. if (comment.length > 2 && c === "*" && reader.peek() === "/") {
  4719. comment += reader.read();
  4720. break;
  4721. }
  4722. c = reader.read();
  4723. }
  4724. return comment;
  4725. } else {
  4726. return "";
  4727. }
  4728. }
  4729. });
  4730. },{"../util/TokenStreamBase":27,"./PropertyValuePart":11,"./Tokens":18}],18:[function(require,module,exports){
  4731. "use strict";
  4732. var Tokens = module.exports = [
  4733. { name: "CDO" },
  4734. { name: "CDC" },
  4735. { name: "S", whitespace: true/*, channel: "ws"*/ },
  4736. { name: "COMMENT", comment: true, hide: true, channel: "comment" },
  4737. { name: "INCLUDES", text: "~=" },
  4738. { name: "DASHMATCH", text: "|=" },
  4739. { name: "PREFIXMATCH", text: "^=" },
  4740. { name: "SUFFIXMATCH", text: "$=" },
  4741. { name: "SUBSTRINGMATCH", text: "*=" },
  4742. { name: "STRING" },
  4743. { name: "IDENT" },
  4744. { name: "HASH" },
  4745. { name: "IMPORT_SYM", text: "@import" },
  4746. { name: "PAGE_SYM", text: "@page" },
  4747. { name: "MEDIA_SYM", text: "@media" },
  4748. { name: "FONT_FACE_SYM", text: "@font-face" },
  4749. { name: "CHARSET_SYM", text: "@charset" },
  4750. { name: "NAMESPACE_SYM", text: "@namespace" },
  4751. { name: "SUPPORTS_SYM", text: "@supports" },
  4752. { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"] },
  4753. { name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"] },
  4754. { name: "UNKNOWN_SYM" },
  4755. { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
  4756. { name: "IMPORTANT_SYM" },
  4757. { name: "LENGTH" },
  4758. { name: "ANGLE" },
  4759. { name: "TIME" },
  4760. { name: "FREQ" },
  4761. { name: "DIMENSION" },
  4762. { name: "PERCENTAGE" },
  4763. { name: "NUMBER" },
  4764. { name: "URI" },
  4765. { name: "FUNCTION" },
  4766. { name: "UNICODE_RANGE" },
  4767. { name: "INVALID" },
  4768. { name: "PLUS", text: "+" },
  4769. { name: "GREATER", text: ">" },
  4770. { name: "COMMA", text: "," },
  4771. { name: "TILDE", text: "~" },
  4772. { name: "NOT" },
  4773. { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner" },
  4774. { name: "TOPLEFT_SYM", text: "@top-left" },
  4775. { name: "TOPCENTER_SYM", text: "@top-center" },
  4776. { name: "TOPRIGHT_SYM", text: "@top-right" },
  4777. { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner" },
  4778. { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner" },
  4779. { name: "BOTTOMLEFT_SYM", text: "@bottom-left" },
  4780. { name: "BOTTOMCENTER_SYM", text: "@bottom-center" },
  4781. { name: "BOTTOMRIGHT_SYM", text: "@bottom-right" },
  4782. { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner" },
  4783. { name: "LEFTTOP_SYM", text: "@left-top" },
  4784. { name: "LEFTMIDDLE_SYM", text: "@left-middle" },
  4785. { name: "LEFTBOTTOM_SYM", text: "@left-bottom" },
  4786. { name: "RIGHTTOP_SYM", text: "@right-top" },
  4787. { name: "RIGHTMIDDLE_SYM", text: "@right-middle" },
  4788. { name: "RIGHTBOTTOM_SYM", text: "@right-bottom" },
  4789. { name: "RESOLUTION", state: "media" },
  4790. { name: "IE_FUNCTION" },
  4791. { name: "CHAR" },
  4792. {
  4793. name: "PIPE",
  4794. text: "|"
  4795. },
  4796. {
  4797. name: "SLASH",
  4798. text: "/"
  4799. },
  4800. {
  4801. name: "MINUS",
  4802. text: "-"
  4803. },
  4804. {
  4805. name: "STAR",
  4806. text: "*"
  4807. },
  4808. {
  4809. name: "LBRACE",
  4810. endChar: "}",
  4811. text: "{"
  4812. },
  4813. {
  4814. name: "RBRACE",
  4815. text: "}"
  4816. },
  4817. {
  4818. name: "LBRACKET",
  4819. endChar: "]",
  4820. text: "["
  4821. },
  4822. {
  4823. name: "RBRACKET",
  4824. text: "]"
  4825. },
  4826. {
  4827. name: "EQUALS",
  4828. text: "="
  4829. },
  4830. {
  4831. name: "COLON",
  4832. text: ":"
  4833. },
  4834. {
  4835. name: "SEMICOLON",
  4836. text: ";"
  4837. },
  4838. {
  4839. name: "LPAREN",
  4840. endChar: ")",
  4841. text: "("
  4842. },
  4843. {
  4844. name: "RPAREN",
  4845. text: ")"
  4846. },
  4847. {
  4848. name: "DOT",
  4849. text: "."
  4850. }
  4851. ];
  4852. (function() {
  4853. var nameMap = [],
  4854. typeMap = Object.create(null);
  4855. Tokens.UNKNOWN = -1;
  4856. Tokens.unshift({ name:"EOF" });
  4857. for (var i = 0, len = Tokens.length; i < len; i++) {
  4858. nameMap.push(Tokens[i].name);
  4859. Tokens[Tokens[i].name] = i;
  4860. if (Tokens[i].text) {
  4861. if (Tokens[i].text instanceof Array) {
  4862. for (var j = 0; j < Tokens[i].text.length; j++) {
  4863. typeMap[Tokens[i].text[j]] = i;
  4864. }
  4865. } else {
  4866. typeMap[Tokens[i].text] = i;
  4867. }
  4868. }
  4869. }
  4870. Tokens.name = function(tt) {
  4871. return nameMap[tt];
  4872. };
  4873. Tokens.type = function(c) {
  4874. return typeMap[c] || -1;
  4875. };
  4876. })();
  4877. },{}],19:[function(require,module,exports){
  4878. "use strict";
  4879. var Matcher = require("./Matcher");
  4880. var Properties = require("./Properties");
  4881. var ValidationTypes = require("./ValidationTypes");
  4882. var ValidationError = require("./ValidationError");
  4883. var PropertyValueIterator = require("./PropertyValueIterator");
  4884. var Validation = module.exports = {
  4885. validate: function(property, value) {
  4886. var name = property.toString().toLowerCase(),
  4887. expression = new PropertyValueIterator(value),
  4888. spec = Properties[name],
  4889. part;
  4890. if (!spec) {
  4891. if (name.indexOf("-") !== 0) { // vendor prefixed are ok
  4892. throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
  4893. }
  4894. } else if (typeof spec !== "number") {
  4895. if (ValidationTypes.isAny(expression, "inherit | initial | unset")) {
  4896. if (expression.hasNext()) {
  4897. part = expression.next();
  4898. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4899. }
  4900. return;
  4901. }
  4902. this.singleProperty(spec, expression);
  4903. }
  4904. },
  4905. singleProperty: function(types, expression) {
  4906. var result = false,
  4907. value = expression.value,
  4908. part;
  4909. result = Matcher.parse(types).match(expression);
  4910. if (!result) {
  4911. if (expression.hasNext() && !expression.isFirst()) {
  4912. part = expression.peek();
  4913. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4914. } else {
  4915. throw new ValidationError("Expected (" + ValidationTypes.describe(types) + ") but found '" + value + "'.", value.line, value.col);
  4916. }
  4917. } else if (expression.hasNext()) {
  4918. part = expression.next();
  4919. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4920. }
  4921. }
  4922. };
  4923. },{"./Matcher":3,"./Properties":7,"./PropertyValueIterator":10,"./ValidationError":20,"./ValidationTypes":21}],20:[function(require,module,exports){
  4924. "use strict";
  4925. module.exports = ValidationError;
  4926. function ValidationError(message, line, col) {
  4927. this.col = col;
  4928. this.line = line;
  4929. this.message = message;
  4930. }
  4931. ValidationError.prototype = new Error();
  4932. },{}],21:[function(require,module,exports){
  4933. "use strict";
  4934. var ValidationTypes = module.exports;
  4935. var Matcher = require("./Matcher");
  4936. function copy(to, from) {
  4937. Object.keys(from).forEach(function(prop) {
  4938. to[prop] = from[prop];
  4939. });
  4940. }
  4941. copy(ValidationTypes, {
  4942. isLiteral: function (part, literals) {
  4943. var text = part.text.toString().toLowerCase(),
  4944. args = literals.split(" | "),
  4945. i,
  4946. len,
  4947. found = false;
  4948. for (i = 0, len = args.length; i < len && !found; i++) {
  4949. if (args[i].charAt(0) === "<") {
  4950. found = this.simple[args[i]](part);
  4951. } else if (args[i].slice(-2) === "()") {
  4952. found = (part.type === "function" &&
  4953. part.name === args[i].slice(0, -2));
  4954. } else if (text === args[i].toLowerCase()) {
  4955. found = true;
  4956. }
  4957. }
  4958. return found;
  4959. },
  4960. isSimple: function(type) {
  4961. return Boolean(this.simple[type]);
  4962. },
  4963. isComplex: function(type) {
  4964. return Boolean(this.complex[type]);
  4965. },
  4966. describe: function(type) {
  4967. if (this.complex[type] instanceof Matcher) {
  4968. return this.complex[type].toString(0);
  4969. }
  4970. return type;
  4971. },
  4972. isAny: function (expression, types) {
  4973. var args = types.split(" | "),
  4974. i,
  4975. len,
  4976. found = false;
  4977. for (i = 0, len = args.length; i < len && !found && expression.hasNext(); i++) {
  4978. found = this.isType(expression, args[i]);
  4979. }
  4980. return found;
  4981. },
  4982. isAnyOfGroup: function(expression, types) {
  4983. var args = types.split(" || "),
  4984. i,
  4985. len,
  4986. found = false;
  4987. for (i = 0, len = args.length; i < len && !found; i++) {
  4988. found = this.isType(expression, args[i]);
  4989. }
  4990. return found ? args[i - 1] : false;
  4991. },
  4992. isType: function (expression, type) {
  4993. var part = expression.peek(),
  4994. result = false;
  4995. if (type.charAt(0) !== "<") {
  4996. result = this.isLiteral(part, type);
  4997. if (result) {
  4998. expression.next();
  4999. }
  5000. } else if (this.simple[type]) {
  5001. result = this.simple[type](part);
  5002. if (result) {
  5003. expression.next();
  5004. }
  5005. } else if (this.complex[type] instanceof Matcher) {
  5006. result = this.complex[type].match(expression);
  5007. } else {
  5008. result = this.complex[type](expression);
  5009. }
  5010. return result;
  5011. },
  5012. simple: {
  5013. __proto__: null,
  5014. "<absolute-size>":
  5015. "xx-small | x-small | small | medium | large | x-large | xx-large",
  5016. "<animateable-feature>":
  5017. "scroll-position | contents | <animateable-feature-name>",
  5018. "<animateable-feature-name>": function(part) {
  5019. return this["<ident>"](part) &&
  5020. !/^(unset|initial|inherit|will-change|auto|scroll-position|contents)$/i.test(part);
  5021. },
  5022. "<angle>": function(part) {
  5023. return part.type === "angle";
  5024. },
  5025. "<attachment>": "scroll | fixed | local",
  5026. "<attr>": "attr()",
  5027. "<basic-shape>": "inset() | circle() | ellipse() | polygon()",
  5028. "<bg-image>": "<image> | <gradient> | none",
  5029. "<border-style>":
  5030. "none | hidden | dotted | dashed | solid | double | groove | " +
  5031. "ridge | inset | outset",
  5032. "<border-width>": "<length> | thin | medium | thick",
  5033. "<box>": "padding-box | border-box | content-box",
  5034. "<clip-source>": "<uri>",
  5035. "<color>": function(part) {
  5036. return part.type === "color" || String(part) === "transparent" || String(part) === "currentColor";
  5037. },
  5038. "<color-svg>": function(part) {
  5039. return part.type === "color";
  5040. },
  5041. "<content>": "content()",
  5042. "<content-sizing>":
  5043. "fill-available | -moz-available | -webkit-fill-available | " +
  5044. "max-content | -moz-max-content | -webkit-max-content | " +
  5045. "min-content | -moz-min-content | -webkit-min-content | " +
  5046. "fit-content | -moz-fit-content | -webkit-fit-content",
  5047. "<feature-tag-value>": function(part) {
  5048. return part.type === "function" && /^[A-Z0-9]{4}$/i.test(part);
  5049. },
  5050. "<filter-function>":
  5051. "blur() | brightness() | contrast() | custom() | " +
  5052. "drop-shadow() | grayscale() | hue-rotate() | invert() | " +
  5053. "opacity() | saturate() | sepia()",
  5054. "<flex-basis>": "<width>",
  5055. "<flex-direction>": "row | row-reverse | column | column-reverse",
  5056. "<flex-grow>": "<number>",
  5057. "<flex-shrink>": "<number>",
  5058. "<flex-wrap>": "nowrap | wrap | wrap-reverse",
  5059. "<font-size>":
  5060. "<absolute-size> | <relative-size> | <length> | <percentage>",
  5061. "<font-stretch>":
  5062. "normal | ultra-condensed | extra-condensed | condensed | " +
  5063. "semi-condensed | semi-expanded | expanded | extra-expanded | " +
  5064. "ultra-expanded",
  5065. "<font-style>": "normal | italic | oblique",
  5066. "<font-variant-caps>":
  5067. "small-caps | all-small-caps | petite-caps | all-petite-caps | " +
  5068. "unicase | titling-caps",
  5069. "<font-variant-css21>": "normal | small-caps",
  5070. "<font-weight>":
  5071. "normal | bold | bolder | lighter | " +
  5072. "100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900",
  5073. "<generic-family>":
  5074. "serif | sans-serif | cursive | fantasy | monospace",
  5075. "<geometry-box>": "<shape-box> | fill-box | stroke-box | view-box",
  5076. "<glyph-angle>": function(part) {
  5077. return part.type === "angle" && part.units === "deg";
  5078. },
  5079. "<gradient>": function(part) {
  5080. return part.type === "function" && /^(?:-(?:ms|moz|o|webkit)-)?(?:repeating-)?(?:radial-|linear-)?gradient/i.test(part);
  5081. },
  5082. "<icccolor>":
  5083. "cielab() | cielch() | cielchab() | " +
  5084. "icc-color() | icc-named-color()",
  5085. "<ident>": function(part) {
  5086. return part.type === "identifier" || part.wasIdent;
  5087. },
  5088. "<ident-not-generic-family>": function(part) {
  5089. return this["<ident>"](part) && !this["<generic-family>"](part);
  5090. },
  5091. "<image>": "<uri>",
  5092. "<integer>": function(part) {
  5093. return part.type === "integer";
  5094. },
  5095. "<length>": function(part) {
  5096. if (part.type === "function" && /^(?:-(?:ms|moz|o|webkit)-)?calc/i.test(part)) {
  5097. return true;
  5098. } else {
  5099. return part.type === "length" || part.type === "number" || part.type === "integer" || String(part) === "0";
  5100. }
  5101. },
  5102. "<line>": function(part) {
  5103. return part.type === "integer";
  5104. },
  5105. "<line-height>": "<number> | <length> | <percentage> | normal",
  5106. "<margin-width>": "<length> | <percentage> | auto",
  5107. "<miterlimit>": function(part) {
  5108. return this["<number>"](part) && part.value >= 1;
  5109. },
  5110. "<nonnegative-length-or-percentage>": function(part) {
  5111. return (this["<length>"](part) || this["<percentage>"](part)) &&
  5112. (String(part) === "0" || part.type === "function" || (part.value) >= 0);
  5113. },
  5114. "<nonnegative-number-or-percentage>": function(part) {
  5115. return (this["<number>"](part) || this["<percentage>"](part)) &&
  5116. (String(part) === "0" || part.type === "function" || (part.value) >= 0);
  5117. },
  5118. "<number>": function(part) {
  5119. return part.type === "number" || this["<integer>"](part);
  5120. },
  5121. "<opacity-value>": function(part) {
  5122. return this["<number>"](part) && part.value >= 0 && part.value <= 1;
  5123. },
  5124. "<padding-width>": "<nonnegative-length-or-percentage>",
  5125. "<percentage>": function(part) {
  5126. return part.type === "percentage" || String(part) === "0";
  5127. },
  5128. "<relative-size>": "smaller | larger",
  5129. "<shape>": "rect() | inset-rect()",
  5130. "<shape-box>": "<box> | margin-box",
  5131. "<single-animation-direction>":
  5132. "normal | reverse | alternate | alternate-reverse",
  5133. "<single-animation-name>": function(part) {
  5134. return this["<ident>"](part) &&
  5135. /^-?[a-z_][-a-z0-9_]+$/i.test(part) &&
  5136. !/^(none|unset|initial|inherit)$/i.test(part);
  5137. },
  5138. "<string>": function(part) {
  5139. return part.type === "string";
  5140. },
  5141. "<time>": function(part) {
  5142. return part.type === "time";
  5143. },
  5144. "<uri>": function(part) {
  5145. return part.type === "uri";
  5146. },
  5147. "<width>": "<margin-width>"
  5148. },
  5149. complex: {
  5150. __proto__: null,
  5151. "<azimuth>":
  5152. "<angle>" +
  5153. " | " +
  5154. "[ [ left-side | far-left | left | center-left | center | " +
  5155. "center-right | right | far-right | right-side ] || behind ]" +
  5156. " | " +
  5157. "leftwards | rightwards",
  5158. "<bg-position>": "<position>#",
  5159. "<bg-size>":
  5160. "[ <length> | <percentage> | auto ]{1,2} | cover | contain",
  5161. "<blend-mode>":
  5162. "normal | multiply | screen | overlay | darken | lighten | color-dodge | " +
  5163. "color-burn | hard-light | soft-light | difference | exclusion | hue | " +
  5164. "saturation | color | luminosity",
  5165. "<border-image-slice>":
  5166. Matcher.many([true /* first element is required */],
  5167. Matcher.cast("<nonnegative-number-or-percentage>"),
  5168. Matcher.cast("<nonnegative-number-or-percentage>"),
  5169. Matcher.cast("<nonnegative-number-or-percentage>"),
  5170. Matcher.cast("<nonnegative-number-or-percentage>"),
  5171. "fill"),
  5172. "<border-radius>":
  5173. "<nonnegative-length-or-percentage>{1,4} " +
  5174. "[ / <nonnegative-length-or-percentage>{1,4} ]?",
  5175. "<box-shadow>": "none | <shadow>#",
  5176. "<clip-path>": "<basic-shape> || <geometry-box>",
  5177. "<dasharray>":
  5178. Matcher.cast("<nonnegative-length-or-percentage>")
  5179. .braces(1, Infinity, "#", Matcher.cast(",").question()),
  5180. "<family-name>":
  5181. "<string> | <ident-not-generic-family> <ident>*",
  5182. "<filter-function-list>": "[ <filter-function> | <uri> ]+",
  5183. "<flex>":
  5184. "none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]",
  5185. "<font-family>": "[ <generic-family> | <family-name> ]#",
  5186. "<font-shorthand>":
  5187. "[ <font-style> || <font-variant-css21> || " +
  5188. "<font-weight> || <font-stretch> ]? <font-size> " +
  5189. "[ / <line-height> ]? <font-family>",
  5190. "<font-variant-alternates>":
  5191. "stylistic() || " +
  5192. "historical-forms || " +
  5193. "styleset() || " +
  5194. "character-variant() || " +
  5195. "swash() || " +
  5196. "ornaments() || " +
  5197. "annotation()",
  5198. "<font-variant-ligatures>":
  5199. "[ common-ligatures | no-common-ligatures ] || " +
  5200. "[ discretionary-ligatures | no-discretionary-ligatures ] || " +
  5201. "[ historical-ligatures | no-historical-ligatures ] || " +
  5202. "[ contextual | no-contextual ]",
  5203. "<font-variant-numeric>":
  5204. "[ lining-nums | oldstyle-nums ] || " +
  5205. "[ proportional-nums | tabular-nums ] || " +
  5206. "[ diagonal-fractions | stacked-fractions ] || " +
  5207. "ordinal || slashed-zero",
  5208. "<font-variant-east-asian>":
  5209. "[ jis78 | jis83 | jis90 | jis04 | simplified | traditional ] || " +
  5210. "[ full-width | proportional-width ] || " +
  5211. "ruby",
  5212. "<paint>": "<paint-basic> | <uri> <paint-basic>?",
  5213. "<paint-basic>": "none | currentColor | <color-svg> <icccolor>?",
  5214. "<position>":
  5215. "[ center | [ left | right ] [ <percentage> | <length> ]? ] && " +
  5216. "[ center | [ top | bottom ] [ <percentage> | <length> ]? ]" +
  5217. " | " +
  5218. "[ left | center | right | <percentage> | <length> ] " +
  5219. "[ top | center | bottom | <percentage> | <length> ]" +
  5220. " | " +
  5221. "[ left | center | right | top | bottom | <percentage> | <length> ]",
  5222. "<repeat-style>":
  5223. "repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}",
  5224. "<shadow>":
  5225. Matcher.many([true /* length is required */],
  5226. Matcher.cast("<length>").braces(2, 4), "inset", "<color>"),
  5227. "<text-decoration-color>":
  5228. "<color>",
  5229. "<text-decoration-line>":
  5230. "none | [ underline || overline || line-through || blink ]",
  5231. "<text-decoration-style>":
  5232. "solid | double | dotted | dashed | wavy",
  5233. "<will-change>":
  5234. "auto | <animateable-feature>#",
  5235. "<x-one-radius>":
  5236. "[ <length> | <percentage> ]{1,2}"
  5237. }
  5238. });
  5239. Object.keys(ValidationTypes.simple).forEach(function(nt) {
  5240. var rule = ValidationTypes.simple[nt];
  5241. if (typeof rule === "string") {
  5242. ValidationTypes.simple[nt] = function(part) {
  5243. return ValidationTypes.isLiteral(part, rule);
  5244. };
  5245. }
  5246. });
  5247. Object.keys(ValidationTypes.complex).forEach(function(nt) {
  5248. var rule = ValidationTypes.complex[nt];
  5249. if (typeof rule === "string") {
  5250. ValidationTypes.complex[nt] = Matcher.parse(rule);
  5251. }
  5252. });
  5253. ValidationTypes.complex["<font-variant>"] =
  5254. Matcher.oror({ expand: "<font-variant-ligatures>" },
  5255. { expand: "<font-variant-alternates>" },
  5256. "<font-variant-caps>",
  5257. { expand: "<font-variant-numeric>" },
  5258. { expand: "<font-variant-east-asian>" });
  5259. },{"./Matcher":3}],22:[function(require,module,exports){
  5260. "use strict";
  5261. module.exports = {
  5262. Colors : require("./Colors"),
  5263. Combinator : require("./Combinator"),
  5264. Parser : require("./Parser"),
  5265. PropertyName : require("./PropertyName"),
  5266. PropertyValue : require("./PropertyValue"),
  5267. PropertyValuePart : require("./PropertyValuePart"),
  5268. Matcher : require("./Matcher"),
  5269. MediaFeature : require("./MediaFeature"),
  5270. MediaQuery : require("./MediaQuery"),
  5271. Selector : require("./Selector"),
  5272. SelectorPart : require("./SelectorPart"),
  5273. SelectorSubPart : require("./SelectorSubPart"),
  5274. Specificity : require("./Specificity"),
  5275. TokenStream : require("./TokenStream"),
  5276. Tokens : require("./Tokens"),
  5277. ValidationError : require("./ValidationError")
  5278. };
  5279. },{"./Colors":1,"./Combinator":2,"./Matcher":3,"./MediaFeature":4,"./MediaQuery":5,"./Parser":6,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./Specificity":16,"./TokenStream":17,"./Tokens":18,"./ValidationError":20}],23:[function(require,module,exports){
  5280. "use strict";
  5281. module.exports = EventTarget;
  5282. function EventTarget() {
  5283. this._listeners = Object.create(null);
  5284. }
  5285. EventTarget.prototype = {
  5286. constructor: EventTarget,
  5287. addListener: function(type, listener) {
  5288. if (!this._listeners[type]) {
  5289. this._listeners[type] = [];
  5290. }
  5291. this._listeners[type].push(listener);
  5292. },
  5293. fire: function(event) {
  5294. if (typeof event === "string") {
  5295. event = { type: event };
  5296. }
  5297. if (typeof event.target !== "undefined") {
  5298. event.target = this;
  5299. }
  5300. if (typeof event.type === "undefined") {
  5301. throw new Error("Event object missing 'type' property.");
  5302. }
  5303. if (this._listeners[event.type]) {
  5304. var listeners = this._listeners[event.type].concat();
  5305. for (var i = 0, len = listeners.length; i < len; i++) {
  5306. listeners[i].call(this, event);
  5307. }
  5308. }
  5309. },
  5310. removeListener: function(type, listener) {
  5311. if (this._listeners[type]) {
  5312. var listeners = this._listeners[type];
  5313. for (var i = 0, len = listeners.length; i < len; i++) {
  5314. if (listeners[i] === listener) {
  5315. listeners.splice(i, 1);
  5316. break;
  5317. }
  5318. }
  5319. }
  5320. }
  5321. };
  5322. },{}],24:[function(require,module,exports){
  5323. "use strict";
  5324. module.exports = StringReader;
  5325. function StringReader(text) {
  5326. this._input = text.replace(/(\r\n?|\n)/g, "\n");
  5327. this._line = 1;
  5328. this._col = 1;
  5329. this._cursor = 0;
  5330. }
  5331. StringReader.prototype = {
  5332. constructor: StringReader,
  5333. getCol: function() {
  5334. return this._col;
  5335. },
  5336. getLine: function() {
  5337. return this._line;
  5338. },
  5339. eof: function() {
  5340. return this._cursor === this._input.length;
  5341. },
  5342. peek: function(count) {
  5343. var c = null;
  5344. count = typeof count === "undefined" ? 1 : count;
  5345. if (this._cursor < this._input.length) {
  5346. c = this._input.charAt(this._cursor + count - 1);
  5347. }
  5348. return c;
  5349. },
  5350. read: function() {
  5351. var c = null;
  5352. if (this._cursor < this._input.length) {
  5353. if (this._input.charAt(this._cursor) === "\n") {
  5354. this._line++;
  5355. this._col = 1;
  5356. } else {
  5357. this._col++;
  5358. }
  5359. c = this._input.charAt(this._cursor++);
  5360. }
  5361. return c;
  5362. },
  5363. mark: function() {
  5364. this._bookmark = {
  5365. cursor: this._cursor,
  5366. line: this._line,
  5367. col: this._col
  5368. };
  5369. },
  5370. reset: function() {
  5371. if (this._bookmark) {
  5372. this._cursor = this._bookmark.cursor;
  5373. this._line = this._bookmark.line;
  5374. this._col = this._bookmark.col;
  5375. delete this._bookmark;
  5376. }
  5377. },
  5378. peekCount: function(count) {
  5379. count = typeof count === "undefined" ? 1 : Math.max(count, 0);
  5380. return this._input.substring(this._cursor, this._cursor + count);
  5381. },
  5382. readTo: function(pattern) {
  5383. var buffer = "",
  5384. c;
  5385. while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) !== buffer.length - pattern.length) {
  5386. c = this.read();
  5387. if (c) {
  5388. buffer += c;
  5389. } else {
  5390. throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
  5391. }
  5392. }
  5393. return buffer;
  5394. },
  5395. readWhile: function(filter) {
  5396. var buffer = "",
  5397. c = this.peek();
  5398. while (c !== null && filter(c)) {
  5399. buffer += this.read();
  5400. c = this.peek();
  5401. }
  5402. return buffer;
  5403. },
  5404. readMatch: function(matcher) {
  5405. var source = this._input.substring(this._cursor),
  5406. value = null;
  5407. if (typeof matcher === "string") {
  5408. if (source.slice(0, matcher.length) === matcher) {
  5409. value = this.readCount(matcher.length);
  5410. }
  5411. } else if (matcher instanceof RegExp) {
  5412. if (matcher.test(source)) {
  5413. value = this.readCount(RegExp.lastMatch.length);
  5414. }
  5415. }
  5416. return value;
  5417. },
  5418. readCount: function(count) {
  5419. var buffer = "";
  5420. while (count--) {
  5421. buffer += this.read();
  5422. }
  5423. return buffer;
  5424. }
  5425. };
  5426. },{}],25:[function(require,module,exports){
  5427. "use strict";
  5428. module.exports = SyntaxError;
  5429. function SyntaxError(message, line, col) {
  5430. Error.call(this);
  5431. this.name = this.constructor.name;
  5432. this.col = col;
  5433. this.line = line;
  5434. this.message = message;
  5435. }
  5436. SyntaxError.prototype = Object.create(Error.prototype); // jshint ignore:line
  5437. SyntaxError.prototype.constructor = SyntaxError; // jshint ignore:line
  5438. },{}],26:[function(require,module,exports){
  5439. "use strict";
  5440. module.exports = SyntaxUnit;
  5441. function SyntaxUnit(text, line, col, type) {
  5442. this.col = col;
  5443. this.line = line;
  5444. this.text = text;
  5445. this.type = type;
  5446. }
  5447. SyntaxUnit.fromToken = function(token) {
  5448. return new SyntaxUnit(token.value, token.startLine, token.startCol);
  5449. };
  5450. SyntaxUnit.prototype = {
  5451. constructor: SyntaxUnit,
  5452. valueOf: function() {
  5453. return this.toString();
  5454. },
  5455. toString: function() {
  5456. return this.text;
  5457. }
  5458. };
  5459. },{}],27:[function(require,module,exports){
  5460. "use strict";
  5461. module.exports = TokenStreamBase;
  5462. var StringReader = require("./StringReader");
  5463. var SyntaxError = require("./SyntaxError");
  5464. function TokenStreamBase(input, tokenData) {
  5465. this._reader = new StringReader(input ? input.toString() : "");
  5466. this._token = null;
  5467. this._tokenData = tokenData;
  5468. this._lt = [];
  5469. this._ltIndex = 0;
  5470. this._ltIndexCache = [];
  5471. }
  5472. TokenStreamBase.createTokenData = function(tokens) {
  5473. var nameMap = [],
  5474. typeMap = Object.create(null),
  5475. tokenData = tokens.concat([]),
  5476. i = 0,
  5477. len = tokenData.length + 1;
  5478. tokenData.UNKNOWN = -1;
  5479. tokenData.unshift({ name:"EOF" });
  5480. for (; i < len; i++) {
  5481. nameMap.push(tokenData[i].name);
  5482. tokenData[tokenData[i].name] = i;
  5483. if (tokenData[i].text) {
  5484. typeMap[tokenData[i].text] = i;
  5485. }
  5486. }
  5487. tokenData.name = function(tt) {
  5488. return nameMap[tt];
  5489. };
  5490. tokenData.type = function(c) {
  5491. return typeMap[c];
  5492. };
  5493. return tokenData;
  5494. };
  5495. TokenStreamBase.prototype = {
  5496. constructor: TokenStreamBase,
  5497. match: function(tokenTypes, channel) {
  5498. if (!(tokenTypes instanceof Array)) {
  5499. tokenTypes = [tokenTypes];
  5500. }
  5501. var tt = this.get(channel),
  5502. i = 0,
  5503. len = tokenTypes.length;
  5504. while (i < len) {
  5505. if (tt === tokenTypes[i++]) {
  5506. return true;
  5507. }
  5508. }
  5509. this.unget();
  5510. return false;
  5511. },
  5512. mustMatch: function(tokenTypes) {
  5513. var token;
  5514. if (!(tokenTypes instanceof Array)) {
  5515. tokenTypes = [tokenTypes];
  5516. }
  5517. if (!this.match.apply(this, arguments)) {
  5518. token = this.LT(1);
  5519. throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
  5520. " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  5521. }
  5522. },
  5523. advance: function(tokenTypes, channel) {
  5524. while (this.LA(0) !== 0 && !this.match(tokenTypes, channel)) {
  5525. this.get();
  5526. }
  5527. return this.LA(0);
  5528. },
  5529. get: function(channel) {
  5530. var tokenInfo = this._tokenData,
  5531. i = 0,
  5532. token,
  5533. info;
  5534. if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length) {
  5535. i++;
  5536. this._token = this._lt[this._ltIndex++];
  5537. info = tokenInfo[this._token.type];
  5538. while ((typeof info.channel !== "undefined" && channel !== info.channel) &&
  5539. this._ltIndex < this._lt.length) {
  5540. this._token = this._lt[this._ltIndex++];
  5541. info = tokenInfo[this._token.type];
  5542. i++;
  5543. }
  5544. if ((typeof info.channel === "undefined" || channel === info.channel) &&
  5545. this._ltIndex <= this._lt.length) {
  5546. this._ltIndexCache.push(i);
  5547. return this._token.type;
  5548. }
  5549. }
  5550. token = this._getToken();
  5551. if (token.type > -1 && !tokenInfo[token.type].hide) {
  5552. token.channel = tokenInfo[token.type].channel;
  5553. this._token = token;
  5554. this._lt.push(token);
  5555. this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
  5556. if (this._lt.length > 5) {
  5557. this._lt.shift();
  5558. }
  5559. if (this._ltIndexCache.length > 5) {
  5560. this._ltIndexCache.shift();
  5561. }
  5562. this._ltIndex = this._lt.length;
  5563. }
  5564. info = tokenInfo[token.type];
  5565. if (info &&
  5566. (info.hide ||
  5567. (typeof info.channel !== "undefined" && channel !== info.channel))) {
  5568. return this.get(channel);
  5569. } else {
  5570. return token.type;
  5571. }
  5572. },
  5573. LA: function(index) {
  5574. var total = index,
  5575. tt;
  5576. if (index > 0) {
  5577. if (index > 5) {
  5578. throw new Error("Too much lookahead.");
  5579. }
  5580. while (total) {
  5581. tt = this.get();
  5582. total--;
  5583. }
  5584. while (total < index) {
  5585. this.unget();
  5586. total++;
  5587. }
  5588. } else if (index < 0) {
  5589. if (this._lt[this._ltIndex + index]) {
  5590. tt = this._lt[this._ltIndex + index].type;
  5591. } else {
  5592. throw new Error("Too much lookbehind.");
  5593. }
  5594. } else {
  5595. tt = this._token.type;
  5596. }
  5597. return tt;
  5598. },
  5599. LT: function(index) {
  5600. this.LA(index);
  5601. return this._lt[this._ltIndex + index - 1];
  5602. },
  5603. peek: function() {
  5604. return this.LA(1);
  5605. },
  5606. token: function() {
  5607. return this._token;
  5608. },
  5609. tokenName: function(tokenType) {
  5610. if (tokenType < 0 || tokenType > this._tokenData.length) {
  5611. return "UNKNOWN_TOKEN";
  5612. } else {
  5613. return this._tokenData[tokenType].name;
  5614. }
  5615. },
  5616. tokenType: function(tokenName) {
  5617. return this._tokenData[tokenName] || -1;
  5618. },
  5619. unget: function() {
  5620. if (this._ltIndexCache.length) {
  5621. this._ltIndex -= this._ltIndexCache.pop();//--;
  5622. this._token = this._lt[this._ltIndex - 1];
  5623. } else {
  5624. throw new Error("Too much lookahead.");
  5625. }
  5626. }
  5627. };
  5628. },{"./StringReader":24,"./SyntaxError":25}],28:[function(require,module,exports){
  5629. "use strict";
  5630. module.exports = {
  5631. StringReader : require("./StringReader"),
  5632. SyntaxError : require("./SyntaxError"),
  5633. SyntaxUnit : require("./SyntaxUnit"),
  5634. EventTarget : require("./EventTarget"),
  5635. TokenStreamBase : require("./TokenStreamBase")
  5636. };
  5637. },{"./EventTarget":23,"./StringReader":24,"./SyntaxError":25,"./SyntaxUnit":26,"./TokenStreamBase":27}],"parserlib":[function(require,module,exports){
  5638. "use strict";
  5639. module.exports = {
  5640. css : require("./css"),
  5641. util : require("./util")
  5642. };
  5643. },{"./css":22,"./util":28}]},{},[]);
  5644. return require('parserlib');
  5645. })();
  5646. var clone = (function() {
  5647. 'use strict';
  5648. function _instanceof(obj, type) {
  5649. return type != null && obj instanceof type;
  5650. }
  5651. var nativeMap;
  5652. try {
  5653. nativeMap = Map;
  5654. } catch(_) {
  5655. nativeMap = function() {};
  5656. }
  5657. var nativeSet;
  5658. try {
  5659. nativeSet = Set;
  5660. } catch(_) {
  5661. nativeSet = function() {};
  5662. }
  5663. var nativePromise;
  5664. try {
  5665. nativePromise = Promise;
  5666. } catch(_) {
  5667. nativePromise = function() {};
  5668. }
  5669. function clone(parent, circular, depth, prototype, includeNonEnumerable) {
  5670. if (typeof circular === 'object') {
  5671. depth = circular.depth;
  5672. prototype = circular.prototype;
  5673. includeNonEnumerable = circular.includeNonEnumerable;
  5674. circular = circular.circular;
  5675. }
  5676. var allParents = [];
  5677. var allChildren = [];
  5678. var useBuffer = typeof Buffer != 'undefined';
  5679. if (typeof circular == 'undefined')
  5680. circular = true;
  5681. if (typeof depth == 'undefined')
  5682. depth = Infinity;
  5683. function _clone(parent, depth) {
  5684. if (parent === null)
  5685. return null;
  5686. if (depth === 0)
  5687. return parent;
  5688. var child;
  5689. var proto;
  5690. if (typeof parent != 'object') {
  5691. return parent;
  5692. }
  5693. if (_instanceof(parent, nativeMap)) {
  5694. child = new nativeMap();
  5695. } else if (_instanceof(parent, nativeSet)) {
  5696. child = new nativeSet();
  5697. } else if (_instanceof(parent, nativePromise)) {
  5698. child = new nativePromise(function (resolve, reject) {
  5699. parent.then(function(value) {
  5700. resolve(_clone(value, depth - 1));
  5701. }, function(err) {
  5702. reject(_clone(err, depth - 1));
  5703. });
  5704. });
  5705. } else if (clone.__isArray(parent)) {
  5706. child = [];
  5707. } else if (clone.__isRegExp(parent)) {
  5708. child = new RegExp(parent.source, __getRegExpFlags(parent));
  5709. if (parent.lastIndex) child.lastIndex = parent.lastIndex;
  5710. } else if (clone.__isDate(parent)) {
  5711. child = new Date(parent.getTime());
  5712. } else if (useBuffer && Buffer.isBuffer(parent)) {
  5713. if (Buffer.allocUnsafe) {
  5714. child = Buffer.allocUnsafe(parent.length);
  5715. } else {
  5716. child = new Buffer(parent.length);
  5717. }
  5718. parent.copy(child);
  5719. return child;
  5720. } else if (_instanceof(parent, Error)) {
  5721. child = Object.create(parent);
  5722. } else {
  5723. if (typeof prototype == 'undefined') {
  5724. proto = Object.getPrototypeOf(parent);
  5725. child = Object.create(proto);
  5726. }
  5727. else {
  5728. child = Object.create(prototype);
  5729. proto = prototype;
  5730. }
  5731. }
  5732. if (circular) {
  5733. var index = allParents.indexOf(parent);
  5734. if (index != -1) {
  5735. return allChildren[index];
  5736. }
  5737. allParents.push(parent);
  5738. allChildren.push(child);
  5739. }
  5740. if (_instanceof(parent, nativeMap)) {
  5741. parent.forEach(function(value, key) {
  5742. var keyChild = _clone(key, depth - 1);
  5743. var valueChild = _clone(value, depth - 1);
  5744. child.set(keyChild, valueChild);
  5745. });
  5746. }
  5747. if (_instanceof(parent, nativeSet)) {
  5748. parent.forEach(function(value) {
  5749. var entryChild = _clone(value, depth - 1);
  5750. child.add(entryChild);
  5751. });
  5752. }
  5753. for (var i in parent) {
  5754. var attrs;
  5755. if (proto) {
  5756. attrs = Object.getOwnPropertyDescriptor(proto, i);
  5757. }
  5758. if (attrs && attrs.set == null) {
  5759. continue;
  5760. }
  5761. child[i] = _clone(parent[i], depth - 1);
  5762. }
  5763. if (Object.getOwnPropertySymbols) {
  5764. var symbols = Object.getOwnPropertySymbols(parent);
  5765. for (var i = 0; i < symbols.length; i++) {
  5766. var symbol = symbols[i];
  5767. var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
  5768. if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
  5769. continue;
  5770. }
  5771. child[symbol] = _clone(parent[symbol], depth - 1);
  5772. if (!descriptor.enumerable) {
  5773. Object.defineProperty(child, symbol, {
  5774. enumerable: false
  5775. });
  5776. }
  5777. }
  5778. }
  5779. if (includeNonEnumerable) {
  5780. var allPropertyNames = Object.getOwnPropertyNames(parent);
  5781. for (var i = 0; i < allPropertyNames.length; i++) {
  5782. var propertyName = allPropertyNames[i];
  5783. var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
  5784. if (descriptor && descriptor.enumerable) {
  5785. continue;
  5786. }
  5787. child[propertyName] = _clone(parent[propertyName], depth - 1);
  5788. Object.defineProperty(child, propertyName, {
  5789. enumerable: false
  5790. });
  5791. }
  5792. }
  5793. return child;
  5794. }
  5795. return _clone(parent, depth);
  5796. }
  5797. clone.clonePrototype = function clonePrototype(parent) {
  5798. if (parent === null)
  5799. return null;
  5800. var c = function () {};
  5801. c.prototype = parent;
  5802. return new c();
  5803. };
  5804. function __objToStr(o) {
  5805. return Object.prototype.toString.call(o);
  5806. }
  5807. clone.__objToStr = __objToStr;
  5808. function __isDate(o) {
  5809. return typeof o === 'object' && __objToStr(o) === '[object Date]';
  5810. }
  5811. clone.__isDate = __isDate;
  5812. function __isArray(o) {
  5813. return typeof o === 'object' && __objToStr(o) === '[object Array]';
  5814. }
  5815. clone.__isArray = __isArray;
  5816. function __isRegExp(o) {
  5817. return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
  5818. }
  5819. clone.__isRegExp = __isRegExp;
  5820. function __getRegExpFlags(re) {
  5821. var flags = '';
  5822. if (re.global) flags += 'g';
  5823. if (re.ignoreCase) flags += 'i';
  5824. if (re.multiline) flags += 'm';
  5825. return flags;
  5826. }
  5827. clone.__getRegExpFlags = __getRegExpFlags;
  5828. return clone;
  5829. })();
  5830. if (typeof module === 'object' && module.exports) {
  5831. module.exports = clone;
  5832. }
  5833. var CSSLint = (function() {
  5834. "use strict";
  5835. var rules = [],
  5836. formatters = [],
  5837. embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//,
  5838. api = new parserlib.util.EventTarget();
  5839. api.version = "1.0.5";
  5840. api.addRule = function(rule) {
  5841. rules.push(rule);
  5842. rules[rule.id] = rule;
  5843. };
  5844. api.clearRules = function() {
  5845. rules = [];
  5846. };
  5847. api.getRules = function() {
  5848. return [].concat(rules).sort(function(a, b) {
  5849. return a.id > b.id ? 1 : 0;
  5850. });
  5851. };
  5852. api.getRuleset = function() {
  5853. var ruleset = {},
  5854. i = 0,
  5855. len = rules.length;
  5856. while (i < len) {
  5857. ruleset[rules[i++].id] = 1; // by default, everything is a warning
  5858. }
  5859. return ruleset;
  5860. };
  5861. function applyEmbeddedRuleset(text, ruleset) {
  5862. var valueMap,
  5863. embedded = text && text.match(embeddedRuleset),
  5864. rules = embedded && embedded[1];
  5865. if (rules) {
  5866. valueMap = {
  5867. "true": 2, // true is error
  5868. "": 1, // blank is warning
  5869. "false": 0, // false is ignore
  5870. "2": 2, // explicit error
  5871. "1": 1, // explicit warning
  5872. "0": 0 // explicit ignore
  5873. };
  5874. rules.toLowerCase().split(",").forEach(function(rule) {
  5875. var pair = rule.split(":"),
  5876. property = pair[0] || "",
  5877. value = pair[1] || "";
  5878. ruleset[property.trim()] = valueMap[value.trim()];
  5879. });
  5880. }
  5881. return ruleset;
  5882. }
  5883. api.addFormatter = function(formatter) {
  5884. formatters[formatter.id] = formatter;
  5885. };
  5886. api.getFormatter = function(formatId) {
  5887. return formatters[formatId];
  5888. };
  5889. api.format = function(results, filename, formatId, options) {
  5890. var formatter = api.getFormatter(formatId),
  5891. result = null;
  5892. if (formatter) {
  5893. result = formatter.startFormat();
  5894. result += formatter.formatResults(results, filename, options || {});
  5895. result += formatter.endFormat();
  5896. }
  5897. return result;
  5898. };
  5899. api.hasFormat = function(formatId) {
  5900. return formatters.hasOwnProperty(formatId);
  5901. };
  5902. api.verify = function(text, ruleset) {
  5903. var i = 0,
  5904. reporter,
  5905. lines,
  5906. allow = {},
  5907. ignore = [],
  5908. report,
  5909. parser = new parserlib.css.Parser({
  5910. starHack: true,
  5911. ieFilters: true,
  5912. underscoreHack: true,
  5913. strict: false
  5914. });
  5915. lines = text.replace(/\n\r?/g, "$split$").split("$split$");
  5916. CSSLint.Util.forEach(lines, function (line, lineno) {
  5917. var allowLine = line && line.match(/\/\*[ \t]*csslint[ \t]+allow:[ \t]*([^\*]*)\*\//i),
  5918. allowRules = allowLine && allowLine[1],
  5919. allowRuleset = {};
  5920. if (allowRules) {
  5921. allowRules.toLowerCase().split(",").forEach(function(allowRule) {
  5922. allowRuleset[allowRule.trim()] = true;
  5923. });
  5924. if (Object.keys(allowRuleset).length > 0) {
  5925. allow[lineno + 1] = allowRuleset;
  5926. }
  5927. }
  5928. });
  5929. var ignoreStart = null,
  5930. ignoreEnd = null;
  5931. CSSLint.Util.forEach(lines, function (line, lineno) {
  5932. if (ignoreStart === null && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
  5933. ignoreStart = lineno;
  5934. }
  5935. if (line.match(/\/\*[ \t]*csslint[ \t]+ignore:end[ \t]*\*\//i)) {
  5936. ignoreEnd = lineno;
  5937. }
  5938. if (ignoreStart !== null && ignoreEnd !== null) {
  5939. ignore.push([ignoreStart, ignoreEnd]);
  5940. ignoreStart = ignoreEnd = null;
  5941. }
  5942. });
  5943. if (ignoreStart !== null) {
  5944. ignore.push([ignoreStart, lines.length]);
  5945. }
  5946. if (!ruleset) {
  5947. ruleset = api.getRuleset();
  5948. }
  5949. if (embeddedRuleset.test(text)) {
  5950. ruleset = clone(ruleset);
  5951. ruleset = applyEmbeddedRuleset(text, ruleset);
  5952. }
  5953. reporter = new Reporter(lines, ruleset, allow, ignore);
  5954. ruleset.errors = 2; // always report parsing errors as errors
  5955. for (i in ruleset) {
  5956. if (ruleset.hasOwnProperty(i) && ruleset[i]) {
  5957. if (rules[i]) {
  5958. rules[i].init(parser, reporter);
  5959. }
  5960. }
  5961. }
  5962. try {
  5963. parser.parse(text);
  5964. } catch (ex) {
  5965. reporter.error("Fatal error, cannot continue: " + ex.message, ex.line, ex.col, {});
  5966. }
  5967. report = {
  5968. messages : reporter.messages,
  5969. stats : reporter.stats,
  5970. ruleset : reporter.ruleset,
  5971. allow : reporter.allow,
  5972. ignore : reporter.ignore
  5973. };
  5974. report.messages.sort(function (a, b) {
  5975. if (a.rollup && !b.rollup) {
  5976. return 1;
  5977. } else if (!a.rollup && b.rollup) {
  5978. return -1;
  5979. } else {
  5980. return a.line - b.line;
  5981. }
  5982. });
  5983. return report;
  5984. };
  5985. return api;
  5986. })();
  5987. function Reporter(lines, ruleset, allow, ignore) {
  5988. "use strict";
  5989. this.messages = [];
  5990. this.stats = [];
  5991. this.lines = lines;
  5992. this.ruleset = ruleset;
  5993. this.allow = allow;
  5994. if (!this.allow) {
  5995. this.allow = {};
  5996. }
  5997. this.ignore = ignore;
  5998. if (!this.ignore) {
  5999. this.ignore = [];
  6000. }
  6001. }
  6002. Reporter.prototype = {
  6003. constructor: Reporter,
  6004. error: function(message, line, col, rule) {
  6005. "use strict";
  6006. this.messages.push({
  6007. type : "error",
  6008. line : line,
  6009. col : col,
  6010. message : message,
  6011. evidence: this.lines[line-1],
  6012. rule : rule || {}
  6013. });
  6014. },
  6015. warn: function(message, line, col, rule) {
  6016. "use strict";
  6017. this.report(message, line, col, rule);
  6018. },
  6019. report: function(message, line, col, rule) {
  6020. "use strict";
  6021. if (this.allow.hasOwnProperty(line) && this.allow[line].hasOwnProperty(rule.id)) {
  6022. return;
  6023. }
  6024. if (this.isIgnored(line)) {
  6025. return;
  6026. }
  6027. this.messages.push({
  6028. type : this.ruleset[rule.id] === 2 ? "error" : "warning",
  6029. line : line,
  6030. col : col,
  6031. message : message,
  6032. evidence: this.lines[line-1],
  6033. rule : rule
  6034. });
  6035. },
  6036. info: function(message, line, col, rule) {
  6037. "use strict";
  6038. this.messages.push({
  6039. type : "info",
  6040. line : line,
  6041. col : col,
  6042. message : message,
  6043. evidence: this.lines[line-1],
  6044. rule : rule
  6045. });
  6046. },
  6047. rollupError: function(message, rule) {
  6048. "use strict";
  6049. this.messages.push({
  6050. type : "error",
  6051. rollup : true,
  6052. message : message,
  6053. rule : rule
  6054. });
  6055. },
  6056. rollupWarn: function(message, rule) {
  6057. "use strict";
  6058. this.messages.push({
  6059. type : "warning",
  6060. rollup : true,
  6061. message : message,
  6062. rule : rule
  6063. });
  6064. },
  6065. stat: function(name, value) {
  6066. "use strict";
  6067. this.stats[name] = value;
  6068. },
  6069. isIgnored: function(line) {
  6070. "use strict";
  6071. var ignore = false;
  6072. CSSLint.Util.forEach(this.ignore, function (range) {
  6073. if (range[0] <= line && line <= range[1]) {
  6074. ignore = true;
  6075. }
  6076. });
  6077. return ignore;
  6078. }
  6079. };
  6080. CSSLint._Reporter = Reporter;
  6081. CSSLint.Util = {
  6082. mix: function(receiver, supplier) {
  6083. "use strict";
  6084. var prop;
  6085. for (prop in supplier) {
  6086. if (supplier.hasOwnProperty(prop)) {
  6087. receiver[prop] = supplier[prop];
  6088. }
  6089. }
  6090. return prop;
  6091. },
  6092. indexOf: function(values, value) {
  6093. "use strict";
  6094. if (values.indexOf) {
  6095. return values.indexOf(value);
  6096. } else {
  6097. for (var i=0, len=values.length; i < len; i++) {
  6098. if (values[i] === value) {
  6099. return i;
  6100. }
  6101. }
  6102. return -1;
  6103. }
  6104. },
  6105. forEach: function(values, func) {
  6106. "use strict";
  6107. if (values.forEach) {
  6108. return values.forEach(func);
  6109. } else {
  6110. for (var i=0, len=values.length; i < len; i++) {
  6111. func(values[i], i, values);
  6112. }
  6113. }
  6114. }
  6115. };
  6116. CSSLint.addRule({
  6117. id: "box-model",
  6118. name: "Beware of broken box size",
  6119. desc: "Don't use width or height when using padding or border.",
  6120. url: "https://github.com/CSSLint/csslint/wiki/Beware-of-box-model-size",
  6121. browsers: "All",
  6122. init: function(parser, reporter) {
  6123. "use strict";
  6124. var rule = this,
  6125. widthProperties = {
  6126. border: 1,
  6127. "border-left": 1,
  6128. "border-right": 1,
  6129. padding: 1,
  6130. "padding-left": 1,
  6131. "padding-right": 1
  6132. },
  6133. heightProperties = {
  6134. border: 1,
  6135. "border-bottom": 1,
  6136. "border-top": 1,
  6137. padding: 1,
  6138. "padding-bottom": 1,
  6139. "padding-top": 1
  6140. },
  6141. properties,
  6142. boxSizing = false;
  6143. function startRule() {
  6144. properties = {};
  6145. boxSizing = false;
  6146. }
  6147. function endRule() {
  6148. var prop, value;
  6149. if (!boxSizing) {
  6150. if (properties.height) {
  6151. for (prop in heightProperties) {
  6152. if (heightProperties.hasOwnProperty(prop) && properties[prop]) {
  6153. value = properties[prop].value;
  6154. if (!(prop === "padding" && value.parts.length === 2 && value.parts[0].value === 0)) {
  6155. reporter.report("Using height with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
  6156. }
  6157. }
  6158. }
  6159. }
  6160. if (properties.width) {
  6161. for (prop in widthProperties) {
  6162. if (widthProperties.hasOwnProperty(prop) && properties[prop]) {
  6163. value = properties[prop].value;
  6164. if (!(prop === "padding" && value.parts.length === 2 && value.parts[1].value === 0)) {
  6165. reporter.report("Using width with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
  6166. }
  6167. }
  6168. }
  6169. }
  6170. }
  6171. }
  6172. parser.addListener("startrule", startRule);
  6173. parser.addListener("startfontface", startRule);
  6174. parser.addListener("startpage", startRule);
  6175. parser.addListener("startpagemargin", startRule);
  6176. parser.addListener("startkeyframerule", startRule);
  6177. parser.addListener("startviewport", startRule);
  6178. parser.addListener("property", function(event) {
  6179. var name = event.property.text.toLowerCase();
  6180. if (heightProperties[name] || widthProperties[name]) {
  6181. if (!/^0\S*$/.test(event.value) && !(name === "border" && event.value.toString() === "none")) {
  6182. properties[name] = {
  6183. line: event.property.line,
  6184. col: event.property.col,
  6185. value: event.value
  6186. };
  6187. }
  6188. } else {
  6189. if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)) {
  6190. properties[name] = 1;
  6191. } else if (name === "box-sizing") {
  6192. boxSizing = true;
  6193. }
  6194. }
  6195. });
  6196. parser.addListener("endrule", endRule);
  6197. parser.addListener("endfontface", endRule);
  6198. parser.addListener("endpage", endRule);
  6199. parser.addListener("endpagemargin", endRule);
  6200. parser.addListener("endkeyframerule", endRule);
  6201. parser.addListener("endviewport", endRule);
  6202. }
  6203. });
  6204. CSSLint.addRule({
  6205. id: "bulletproof-font-face",
  6206. name: "Use the bulletproof @font-face syntax",
  6207. desc: "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",
  6208. url: "https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face",
  6209. browsers: "All",
  6210. init: function(parser, reporter) {
  6211. "use strict";
  6212. var rule = this,
  6213. fontFaceRule = false,
  6214. firstSrc = true,
  6215. ruleFailed = false,
  6216. line, col;
  6217. parser.addListener("startfontface", function() {
  6218. fontFaceRule = true;
  6219. });
  6220. parser.addListener("property", function(event) {
  6221. if (!fontFaceRule) {
  6222. return;
  6223. }
  6224. var propertyName = event.property.toString().toLowerCase(),
  6225. value = event.value.toString();
  6226. line = event.line;
  6227. col = event.col;
  6228. if (propertyName === "src") {
  6229. var regex = /^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;
  6230. if (!value.match(regex) && firstSrc) {
  6231. ruleFailed = true;
  6232. firstSrc = false;
  6233. } else if (value.match(regex) && !firstSrc) {
  6234. ruleFailed = false;
  6235. }
  6236. }
  6237. });
  6238. parser.addListener("endfontface", function() {
  6239. fontFaceRule = false;
  6240. if (ruleFailed) {
  6241. reporter.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.", line, col, rule);
  6242. }
  6243. });
  6244. }
  6245. });
  6246. CSSLint.addRule({
  6247. id: "compatible-vendor-prefixes",
  6248. name: "Require compatible vendor prefixes",
  6249. desc: "Include all compatible vendor prefixes to reach a wider range of users.",
  6250. url: "https://github.com/CSSLint/csslint/wiki/Require-compatible-vendor-prefixes",
  6251. browsers: "All",
  6252. init: function (parser, reporter) {
  6253. "use strict";
  6254. var rule = this,
  6255. compatiblePrefixes,
  6256. properties,
  6257. prop,
  6258. variations,
  6259. prefixed,
  6260. i,
  6261. len,
  6262. inKeyFrame = false,
  6263. arrayPush = Array.prototype.push,
  6264. applyTo = [];
  6265. compatiblePrefixes = {
  6266. "animation" : "webkit",
  6267. "animation-delay" : "webkit",
  6268. "animation-direction" : "webkit",
  6269. "animation-duration" : "webkit",
  6270. "animation-fill-mode" : "webkit",
  6271. "animation-iteration-count" : "webkit",
  6272. "animation-name" : "webkit",
  6273. "animation-play-state" : "webkit",
  6274. "animation-timing-function" : "webkit",
  6275. "appearance" : "webkit moz",
  6276. "border-end" : "webkit moz",
  6277. "border-end-color" : "webkit moz",
  6278. "border-end-style" : "webkit moz",
  6279. "border-end-width" : "webkit moz",
  6280. "border-image" : "webkit moz o",
  6281. "border-radius" : "webkit",
  6282. "border-start" : "webkit moz",
  6283. "border-start-color" : "webkit moz",
  6284. "border-start-style" : "webkit moz",
  6285. "border-start-width" : "webkit moz",
  6286. "box-align" : "webkit moz",
  6287. "box-direction" : "webkit moz",
  6288. "box-flex" : "webkit moz",
  6289. "box-lines" : "webkit",
  6290. "box-ordinal-group" : "webkit moz",
  6291. "box-orient" : "webkit moz",
  6292. "box-pack" : "webkit moz",
  6293. "box-sizing" : "",
  6294. "box-shadow" : "",
  6295. "column-count" : "webkit moz ms",
  6296. "column-gap" : "webkit moz ms",
  6297. "column-rule" : "webkit moz ms",
  6298. "column-rule-color" : "webkit moz ms",
  6299. "column-rule-style" : "webkit moz ms",
  6300. "column-rule-width" : "webkit moz ms",
  6301. "column-width" : "webkit moz ms",
  6302. "flex" : "webkit ms",
  6303. "flex-basis" : "webkit",
  6304. "flex-direction" : "webkit ms",
  6305. "flex-flow" : "webkit",
  6306. "flex-grow" : "webkit",
  6307. "flex-shrink" : "webkit",
  6308. "hyphens" : "epub moz",
  6309. "line-break" : "webkit ms",
  6310. "margin-end" : "webkit moz",
  6311. "margin-start" : "webkit moz",
  6312. "marquee-speed" : "webkit wap",
  6313. "marquee-style" : "webkit wap",
  6314. "padding-end" : "webkit moz",
  6315. "padding-start" : "webkit moz",
  6316. "tab-size" : "moz o",
  6317. "text-size-adjust" : "webkit ms",
  6318. "transform" : "webkit ms",
  6319. "transform-origin" : "webkit ms",
  6320. "transition" : "",
  6321. "transition-delay" : "",
  6322. "transition-duration" : "",
  6323. "transition-property" : "",
  6324. "transition-timing-function" : "",
  6325. "user-modify" : "webkit moz",
  6326. "user-select" : "webkit moz ms",
  6327. "word-break" : "epub ms",
  6328. "writing-mode" : "epub ms"
  6329. };
  6330. for (prop in compatiblePrefixes) {
  6331. if (compatiblePrefixes.hasOwnProperty(prop)) {
  6332. variations = [];
  6333. prefixed = compatiblePrefixes[prop].split(" ");
  6334. for (i = 0, len = prefixed.length; i < len; i++) {
  6335. variations.push("-" + prefixed[i] + "-" + prop);
  6336. }
  6337. compatiblePrefixes[prop] = variations;
  6338. arrayPush.apply(applyTo, variations);
  6339. }
  6340. }
  6341. parser.addListener("startrule", function () {
  6342. properties = [];
  6343. });
  6344. parser.addListener("startkeyframes", function (event) {
  6345. inKeyFrame = event.prefix || true;
  6346. });
  6347. parser.addListener("endkeyframes", function () {
  6348. inKeyFrame = false;
  6349. });
  6350. parser.addListener("property", function (event) {
  6351. var name = event.property;
  6352. if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
  6353. if (!inKeyFrame || typeof inKeyFrame !== "string" ||
  6354. name.text.indexOf("-" + inKeyFrame + "-") !== 0) {
  6355. properties.push(name);
  6356. }
  6357. }
  6358. });
  6359. parser.addListener("endrule", function () {
  6360. if (!properties.length) {
  6361. return;
  6362. }
  6363. var propertyGroups = {},
  6364. i,
  6365. len,
  6366. name,
  6367. prop,
  6368. variations,
  6369. value,
  6370. full,
  6371. actual,
  6372. item,
  6373. propertiesSpecified;
  6374. for (i = 0, len = properties.length; i < len; i++) {
  6375. name = properties[i];
  6376. for (prop in compatiblePrefixes) {
  6377. if (compatiblePrefixes.hasOwnProperty(prop)) {
  6378. variations = compatiblePrefixes[prop];
  6379. if (CSSLint.Util.indexOf(variations, name.text) > -1) {
  6380. if (!propertyGroups[prop]) {
  6381. propertyGroups[prop] = {
  6382. full: variations.slice(0),
  6383. actual: [],
  6384. actualNodes: []
  6385. };
  6386. }
  6387. if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name.text) === -1) {
  6388. propertyGroups[prop].actual.push(name.text);
  6389. propertyGroups[prop].actualNodes.push(name);
  6390. }
  6391. }
  6392. }
  6393. }
  6394. }
  6395. for (prop in propertyGroups) {
  6396. if (propertyGroups.hasOwnProperty(prop)) {
  6397. value = propertyGroups[prop];
  6398. full = value.full;
  6399. actual = value.actual;
  6400. if (full.length > actual.length) {
  6401. for (i = 0, len = full.length; i < len; i++) {
  6402. item = full[i];
  6403. if (CSSLint.Util.indexOf(actual, item) === -1) {
  6404. propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length === 2) ? actual.join(" and ") : actual.join(", ");
  6405. reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
  6406. }
  6407. }
  6408. }
  6409. }
  6410. }
  6411. });
  6412. }
  6413. });
  6414. CSSLint.addRule({
  6415. id: "display-property-grouping",
  6416. name: "Require properties appropriate for display",
  6417. desc: "Certain properties shouldn't be used with certain display property values.",
  6418. url: "https://github.com/CSSLint/csslint/wiki/Require-properties-appropriate-for-display",
  6419. browsers: "All",
  6420. init: function(parser, reporter) {
  6421. "use strict";
  6422. var rule = this;
  6423. var propertiesToCheck = {
  6424. display: 1,
  6425. "float": "none",
  6426. height: 1,
  6427. width: 1,
  6428. margin: 1,
  6429. "margin-left": 1,
  6430. "margin-right": 1,
  6431. "margin-bottom": 1,
  6432. "margin-top": 1,
  6433. padding: 1,
  6434. "padding-left": 1,
  6435. "padding-right": 1,
  6436. "padding-bottom": 1,
  6437. "padding-top": 1,
  6438. "vertical-align": 1
  6439. },
  6440. properties;
  6441. function reportProperty(name, display, msg) {
  6442. if (properties[name]) {
  6443. if (typeof propertiesToCheck[name] !== "string" || properties[name].value.toLowerCase() !== propertiesToCheck[name]) {
  6444. reporter.report(msg || name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
  6445. }
  6446. }
  6447. }
  6448. function startRule() {
  6449. properties = {};
  6450. }
  6451. function endRule() {
  6452. var display = properties.display ? properties.display.value : null;
  6453. if (display) {
  6454. switch (display) {
  6455. case "inline":
  6456. reportProperty("height", display);
  6457. reportProperty("width", display);
  6458. reportProperty("margin", display);
  6459. reportProperty("margin-top", display);
  6460. reportProperty("margin-bottom", display);
  6461. reportProperty("float", display, "display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");
  6462. break;
  6463. case "block":
  6464. reportProperty("vertical-align", display);
  6465. break;
  6466. case "inline-block":
  6467. reportProperty("float", display);
  6468. break;
  6469. default:
  6470. if (display.indexOf("table-") === 0) {
  6471. reportProperty("margin", display);
  6472. reportProperty("margin-left", display);
  6473. reportProperty("margin-right", display);
  6474. reportProperty("margin-top", display);
  6475. reportProperty("margin-bottom", display);
  6476. reportProperty("float", display);
  6477. }
  6478. }
  6479. }
  6480. }
  6481. parser.addListener("startrule", startRule);
  6482. parser.addListener("startfontface", startRule);
  6483. parser.addListener("startkeyframerule", startRule);
  6484. parser.addListener("startpagemargin", startRule);
  6485. parser.addListener("startpage", startRule);
  6486. parser.addListener("startviewport", startRule);
  6487. parser.addListener("property", function(event) {
  6488. var name = event.property.text.toLowerCase();
  6489. if (propertiesToCheck[name]) {
  6490. properties[name] = {
  6491. value: event.value.text,
  6492. line: event.property.line,
  6493. col: event.property.col
  6494. };
  6495. }
  6496. });
  6497. parser.addListener("endrule", endRule);
  6498. parser.addListener("endfontface", endRule);
  6499. parser.addListener("endkeyframerule", endRule);
  6500. parser.addListener("endpagemargin", endRule);
  6501. parser.addListener("endpage", endRule);
  6502. parser.addListener("endviewport", endRule);
  6503. }
  6504. });
  6505. CSSLint.addRule({
  6506. id: "duplicate-background-images",
  6507. name: "Disallow duplicate background images",
  6508. desc: "Every background-image should be unique. Use a common class for e.g. sprites.",
  6509. url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-background-images",
  6510. browsers: "All",
  6511. init: function(parser, reporter) {
  6512. "use strict";
  6513. var rule = this,
  6514. stack = {};
  6515. parser.addListener("property", function(event) {
  6516. var name = event.property.text,
  6517. value = event.value,
  6518. i, len;
  6519. if (name.match(/background/i)) {
  6520. for (i=0, len=value.parts.length; i < len; i++) {
  6521. if (value.parts[i].type === "uri") {
  6522. if (typeof stack[value.parts[i].uri] === "undefined") {
  6523. stack[value.parts[i].uri] = event;
  6524. } else {
  6525. reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
  6526. }
  6527. }
  6528. }
  6529. }
  6530. });
  6531. }
  6532. });
  6533. CSSLint.addRule({
  6534. id: "duplicate-properties",
  6535. name: "Disallow duplicate properties",
  6536. desc: "Duplicate properties must appear one after the other.",
  6537. url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-properties",
  6538. browsers: "All",
  6539. init: function(parser, reporter) {
  6540. "use strict";
  6541. var rule = this,
  6542. properties,
  6543. lastProperty;
  6544. function startRule() {
  6545. properties = {};
  6546. }
  6547. parser.addListener("startrule", startRule);
  6548. parser.addListener("startfontface", startRule);
  6549. parser.addListener("startpage", startRule);
  6550. parser.addListener("startpagemargin", startRule);
  6551. parser.addListener("startkeyframerule", startRule);
  6552. parser.addListener("startviewport", startRule);
  6553. parser.addListener("property", function(event) {
  6554. var property = event.property,
  6555. name = property.text.toLowerCase();
  6556. if (properties[name] && (lastProperty !== name || properties[name] === event.value.text)) {
  6557. reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
  6558. }
  6559. properties[name] = event.value.text;
  6560. lastProperty = name;
  6561. });
  6562. }
  6563. });
  6564. CSSLint.addRule({
  6565. id: "empty-rules",
  6566. name: "Disallow empty rules",
  6567. desc: "Rules without any properties specified should be removed.",
  6568. url: "https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules",
  6569. browsers: "All",
  6570. init: function(parser, reporter) {
  6571. "use strict";
  6572. var rule = this,
  6573. count = 0;
  6574. parser.addListener("startrule", function() {
  6575. count=0;
  6576. });
  6577. parser.addListener("property", function() {
  6578. count++;
  6579. });
  6580. parser.addListener("endrule", function(event) {
  6581. var selectors = event.selectors;
  6582. if (count === 0) {
  6583. reporter.report("Rule is empty.", selectors[0].line, selectors[0].col, rule);
  6584. }
  6585. });
  6586. }
  6587. });
  6588. CSSLint.addRule({
  6589. id: "errors",
  6590. name: "Parsing Errors",
  6591. desc: "This rule looks for recoverable syntax errors.",
  6592. browsers: "All",
  6593. init: function(parser, reporter) {
  6594. "use strict";
  6595. var rule = this;
  6596. parser.addListener("error", function(event) {
  6597. reporter.error(event.message, event.line, event.col, rule);
  6598. });
  6599. }
  6600. });
  6601. CSSLint.addRule({
  6602. id: "floats",
  6603. name: "Disallow too many floats",
  6604. desc: "This rule tests if the float property is used too many times",
  6605. url: "https://github.com/CSSLint/csslint/wiki/Disallow-too-many-floats",
  6606. browsers: "All",
  6607. init: function(parser, reporter) {
  6608. "use strict";
  6609. var rule = this;
  6610. var count = 0;
  6611. parser.addListener("property", function(event) {
  6612. if (!reporter.isIgnored(event.property.line)) {
  6613. if (event.property.text.toLowerCase() === "float" &&
  6614. event.value.text.toLowerCase() !== "none") {
  6615. count++;
  6616. }
  6617. }
  6618. });
  6619. parser.addListener("endstylesheet", function() {
  6620. reporter.stat("floats", count);
  6621. if (count >= 10) {
  6622. reporter.rollupWarn("Too many floats (" + count + "), you're probably using them for layout. Consider using a grid system instead.", rule);
  6623. }
  6624. });
  6625. }
  6626. });
  6627. CSSLint.addRule({
  6628. id: "font-faces",
  6629. name: "Don't use too many web fonts",
  6630. desc: "Too many different web fonts in the same stylesheet.",
  6631. url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-web-fonts",
  6632. browsers: "All",
  6633. init: function(parser, reporter) {
  6634. "use strict";
  6635. var rule = this,
  6636. count = 0;
  6637. parser.addListener("startfontface", function(event) {
  6638. if (!reporter.isIgnored(event.line)) {
  6639. count++;
  6640. }
  6641. });
  6642. parser.addListener("endstylesheet", function() {
  6643. if (count > 5) {
  6644. reporter.rollupWarn("Too many @font-face declarations (" + count + ").", rule);
  6645. }
  6646. });
  6647. }
  6648. });
  6649. CSSLint.addRule({
  6650. id: "font-sizes",
  6651. name: "Disallow too many font sizes",
  6652. desc: "Checks the number of font-size declarations.",
  6653. url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-font-size-declarations",
  6654. browsers: "All",
  6655. init: function(parser, reporter) {
  6656. "use strict";
  6657. var rule = this,
  6658. count = 0;
  6659. parser.addListener("property", function(event) {
  6660. if (!reporter.isIgnored(event.property.line)) {
  6661. if (event.property.toString() === "font-size") {
  6662. count++;
  6663. }
  6664. }
  6665. });
  6666. parser.addListener("endstylesheet", function() {
  6667. reporter.stat("font-sizes", count);
  6668. if (count >= 10) {
  6669. reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
  6670. }
  6671. });
  6672. }
  6673. });
  6674. CSSLint.addRule({
  6675. id: "gradients",
  6676. name: "Require all gradient definitions",
  6677. desc: "When using a vendor-prefixed gradient, make sure to use them all.",
  6678. url: "https://github.com/CSSLint/csslint/wiki/Require-all-gradient-definitions",
  6679. browsers: "All",
  6680. init: function(parser, reporter) {
  6681. "use strict";
  6682. var rule = this,
  6683. gradients;
  6684. parser.addListener("startrule", function() {
  6685. gradients = {
  6686. moz: 0,
  6687. webkit: 0,
  6688. oldWebkit: 0,
  6689. o: 0
  6690. };
  6691. });
  6692. parser.addListener("property", function(event) {
  6693. if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)) {
  6694. gradients[RegExp.$1] = 1;
  6695. } else if (/\-webkit\-gradient/i.test(event.value)) {
  6696. gradients.oldWebkit = 1;
  6697. }
  6698. });
  6699. parser.addListener("endrule", function(event) {
  6700. var missing = [];
  6701. if (!gradients.moz) {
  6702. missing.push("Firefox 3.6+");
  6703. }
  6704. if (!gradients.webkit) {
  6705. missing.push("Webkit (Safari 5+, Chrome)");
  6706. }
  6707. if (!gradients.oldWebkit) {
  6708. missing.push("Old Webkit (Safari 4+, Chrome)");
  6709. }
  6710. if (!gradients.o) {
  6711. missing.push("Opera 11.1+");
  6712. }
  6713. if (missing.length && missing.length < 4) {
  6714. reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
  6715. }
  6716. });
  6717. }
  6718. });
  6719. CSSLint.addRule({
  6720. id: "ids",
  6721. name: "Disallow IDs in selectors",
  6722. desc: "Selectors should not contain IDs.",
  6723. url: "https://github.com/CSSLint/csslint/wiki/Disallow-IDs-in-selectors",
  6724. browsers: "All",
  6725. init: function(parser, reporter) {
  6726. "use strict";
  6727. var rule = this;
  6728. parser.addListener("startrule", function(event) {
  6729. var selectors = event.selectors,
  6730. selector,
  6731. part,
  6732. modifier,
  6733. idCount,
  6734. i, j, k;
  6735. for (i=0; i < selectors.length; i++) {
  6736. selector = selectors[i];
  6737. idCount = 0;
  6738. for (j=0; j < selector.parts.length; j++) {
  6739. part = selector.parts[j];
  6740. if (part.type === parser.SELECTOR_PART_TYPE) {
  6741. for (k=0; k < part.modifiers.length; k++) {
  6742. modifier = part.modifiers[k];
  6743. if (modifier.type === "id") {
  6744. idCount++;
  6745. }
  6746. }
  6747. }
  6748. }
  6749. if (idCount === 1) {
  6750. reporter.report("Don't use IDs in selectors.", selector.line, selector.col, rule);
  6751. } else if (idCount > 1) {
  6752. reporter.report(idCount + " IDs in the selector, really?", selector.line, selector.col, rule);
  6753. }
  6754. }
  6755. });
  6756. }
  6757. });
  6758. CSSLint.addRule({
  6759. id: "import-ie-limit",
  6760. name: "@import limit on IE6-IE9",
  6761. desc: "IE6-9 supports up to 31 @import per stylesheet",
  6762. browsers: "IE6, IE7, IE8, IE9",
  6763. init: function(parser, reporter) {
  6764. "use strict";
  6765. var rule = this,
  6766. MAX_IMPORT_COUNT = 31,
  6767. count = 0;
  6768. function startPage() {
  6769. count = 0;
  6770. }
  6771. parser.addListener("startpage", startPage);
  6772. parser.addListener("import", function() {
  6773. count++;
  6774. });
  6775. parser.addListener("endstylesheet", function() {
  6776. if (count > MAX_IMPORT_COUNT) {
  6777. reporter.rollupError(
  6778. "Too many @import rules (" + count + "). IE6-9 supports up to 31 import per stylesheet.",
  6779. rule
  6780. );
  6781. }
  6782. });
  6783. }
  6784. });
  6785. CSSLint.addRule({
  6786. id: "import",
  6787. name: "Disallow @import",
  6788. desc: "Don't use @import, use <link> instead.",
  6789. url: "https://github.com/CSSLint/csslint/wiki/Disallow-%40import",
  6790. browsers: "All",
  6791. init: function(parser, reporter) {
  6792. "use strict";
  6793. var rule = this;
  6794. parser.addListener("import", function(event) {
  6795. reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
  6796. });
  6797. }
  6798. });
  6799. CSSLint.addRule({
  6800. id: "important",
  6801. name: "Disallow !important",
  6802. desc: "Be careful when using !important declaration",
  6803. url: "https://github.com/CSSLint/csslint/wiki/Disallow-%21important",
  6804. browsers: "All",
  6805. init: function(parser, reporter) {
  6806. "use strict";
  6807. var rule = this,
  6808. count = 0;
  6809. parser.addListener("property", function(event) {
  6810. if (!reporter.isIgnored(event.line)) {
  6811. if (event.important === true) {
  6812. count++;
  6813. reporter.report("Use of !important", event.line, event.col, rule);
  6814. }
  6815. }
  6816. });
  6817. parser.addListener("endstylesheet", function() {
  6818. reporter.stat("important", count);
  6819. if (count >= 10) {
  6820. reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
  6821. }
  6822. });
  6823. }
  6824. });
  6825. CSSLint.addRule({
  6826. id: "known-properties",
  6827. name: "Require use of known properties",
  6828. desc: "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",
  6829. url: "https://github.com/CSSLint/csslint/wiki/Require-use-of-known-properties",
  6830. browsers: "All",
  6831. init: function(parser, reporter) {
  6832. "use strict";
  6833. var rule = this;
  6834. parser.addListener("property", function(event) {
  6835. if (event.invalid) {
  6836. reporter.report(event.invalid.message, event.line, event.col, rule);
  6837. }
  6838. });
  6839. }
  6840. });
  6841. CSSLint.addRule({
  6842. id: "order-alphabetical",
  6843. name: "Alphabetical order",
  6844. desc: "Assure properties are in alphabetical order",
  6845. browsers: "All",
  6846. init: function(parser, reporter) {
  6847. "use strict";
  6848. var rule = this,
  6849. properties;
  6850. var startRule = function () {
  6851. properties = [];
  6852. };
  6853. var endRule = function(event) {
  6854. var currentProperties = properties.join(","),
  6855. expectedProperties = properties.sort().join(",");
  6856. if (currentProperties !== expectedProperties) {
  6857. reporter.report("Rule doesn't have all its properties in alphabetical order.", event.line, event.col, rule);
  6858. }
  6859. };
  6860. parser.addListener("startrule", startRule);
  6861. parser.addListener("startfontface", startRule);
  6862. parser.addListener("startpage", startRule);
  6863. parser.addListener("startpagemargin", startRule);
  6864. parser.addListener("startkeyframerule", startRule);
  6865. parser.addListener("startviewport", startRule);
  6866. parser.addListener("property", function(event) {
  6867. var name = event.property.text,
  6868. lowerCasePrefixLessName = name.toLowerCase().replace(/^-.*?-/, "");
  6869. properties.push(lowerCasePrefixLessName);
  6870. });
  6871. parser.addListener("endrule", endRule);
  6872. parser.addListener("endfontface", endRule);
  6873. parser.addListener("endpage", endRule);
  6874. parser.addListener("endpagemargin", endRule);
  6875. parser.addListener("endkeyframerule", endRule);
  6876. parser.addListener("endviewport", endRule);
  6877. }
  6878. });
  6879. CSSLint.addRule({
  6880. id: "outline-none",
  6881. name: "Disallow outline: none",
  6882. desc: "Use of outline: none or outline: 0 should be limited to :focus rules.",
  6883. url: "https://github.com/CSSLint/csslint/wiki/Disallow-outline%3Anone",
  6884. browsers: "All",
  6885. tags: ["Accessibility"],
  6886. init: function(parser, reporter) {
  6887. "use strict";
  6888. var rule = this,
  6889. lastRule;
  6890. function startRule(event) {
  6891. if (event.selectors) {
  6892. lastRule = {
  6893. line: event.line,
  6894. col: event.col,
  6895. selectors: event.selectors,
  6896. propCount: 0,
  6897. outline: false
  6898. };
  6899. } else {
  6900. lastRule = null;
  6901. }
  6902. }
  6903. function endRule() {
  6904. if (lastRule) {
  6905. if (lastRule.outline) {
  6906. if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") === -1) {
  6907. reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
  6908. } else if (lastRule.propCount === 1) {
  6909. reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
  6910. }
  6911. }
  6912. }
  6913. }
  6914. parser.addListener("startrule", startRule);
  6915. parser.addListener("startfontface", startRule);
  6916. parser.addListener("startpage", startRule);
  6917. parser.addListener("startpagemargin", startRule);
  6918. parser.addListener("startkeyframerule", startRule);
  6919. parser.addListener("startviewport", startRule);
  6920. parser.addListener("property", function(event) {
  6921. var name = event.property.text.toLowerCase(),
  6922. value = event.value;
  6923. if (lastRule) {
  6924. lastRule.propCount++;
  6925. if (name === "outline" && (value.toString() === "none" || value.toString() === "0")) {
  6926. lastRule.outline = true;
  6927. }
  6928. }
  6929. });
  6930. parser.addListener("endrule", endRule);
  6931. parser.addListener("endfontface", endRule);
  6932. parser.addListener("endpage", endRule);
  6933. parser.addListener("endpagemargin", endRule);
  6934. parser.addListener("endkeyframerule", endRule);
  6935. parser.addListener("endviewport", endRule);
  6936. }
  6937. });
  6938. CSSLint.addRule({
  6939. id: "overqualified-elements",
  6940. name: "Disallow overqualified elements",
  6941. desc: "Don't use classes or IDs with elements (a.foo or a#foo).",
  6942. url: "https://github.com/CSSLint/csslint/wiki/Disallow-overqualified-elements",
  6943. browsers: "All",
  6944. init: function(parser, reporter) {
  6945. "use strict";
  6946. var rule = this,
  6947. classes = {};
  6948. parser.addListener("startrule", function(event) {
  6949. var selectors = event.selectors,
  6950. selector,
  6951. part,
  6952. modifier,
  6953. i, j, k;
  6954. for (i=0; i < selectors.length; i++) {
  6955. selector = selectors[i];
  6956. for (j=0; j < selector.parts.length; j++) {
  6957. part = selector.parts[j];
  6958. if (part.type === parser.SELECTOR_PART_TYPE) {
  6959. for (k=0; k < part.modifiers.length; k++) {
  6960. modifier = part.modifiers[k];
  6961. if (part.elementName && modifier.type === "id") {
  6962. reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
  6963. } else if (modifier.type === "class") {
  6964. if (!classes[modifier]) {
  6965. classes[modifier] = [];
  6966. }
  6967. classes[modifier].push({
  6968. modifier: modifier,
  6969. part: part
  6970. });
  6971. }
  6972. }
  6973. }
  6974. }
  6975. }
  6976. });
  6977. parser.addListener("endstylesheet", function() {
  6978. var prop;
  6979. for (prop in classes) {
  6980. if (classes.hasOwnProperty(prop)) {
  6981. if (classes[prop].length === 1 && classes[prop][0].part.elementName) {
  6982. reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
  6983. }
  6984. }
  6985. }
  6986. });
  6987. }
  6988. });
  6989. CSSLint.addRule({
  6990. id: "regex-selectors",
  6991. name: "Disallow selectors that look like regexs",
  6992. desc: "Selectors that look like regular expressions are slow and should be avoided.",
  6993. url: "https://github.com/CSSLint/csslint/wiki/Disallow-selectors-that-look-like-regular-expressions",
  6994. browsers: "All",
  6995. init: function(parser, reporter) {
  6996. "use strict";
  6997. var rule = this;
  6998. parser.addListener("startrule", function(event) {
  6999. var selectors = event.selectors,
  7000. selector,
  7001. part,
  7002. modifier,
  7003. i, j, k;
  7004. for (i=0; i < selectors.length; i++) {
  7005. selector = selectors[i];
  7006. for (j=0; j < selector.parts.length; j++) {
  7007. part = selector.parts[j];
  7008. if (part.type === parser.SELECTOR_PART_TYPE) {
  7009. for (k=0; k < part.modifiers.length; k++) {
  7010. modifier = part.modifiers[k];
  7011. if (modifier.type === "attribute") {
  7012. if (/([~\|\^\$\*]=)/.test(modifier)) {
  7013. reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
  7014. }
  7015. }
  7016. }
  7017. }
  7018. }
  7019. }
  7020. });
  7021. }
  7022. });
  7023. CSSLint.addRule({
  7024. id: "rules-count",
  7025. name: "Rules Count",
  7026. desc: "Track how many rules there are.",
  7027. browsers: "All",
  7028. init: function(parser, reporter) {
  7029. "use strict";
  7030. var count = 0;
  7031. parser.addListener("startrule", function() {
  7032. count++;
  7033. });
  7034. parser.addListener("endstylesheet", function() {
  7035. reporter.stat("rule-count", count);
  7036. });
  7037. }
  7038. });
  7039. CSSLint.addRule({
  7040. id: "selector-max-approaching",
  7041. name: "Warn when approaching the 4095 selector limit for IE",
  7042. desc: "Will warn when selector count is >= 3800 selectors.",
  7043. browsers: "IE",
  7044. init: function(parser, reporter) {
  7045. "use strict";
  7046. var rule = this, count = 0;
  7047. parser.addListener("startrule", function(event) {
  7048. count += event.selectors.length;
  7049. });
  7050. parser.addListener("endstylesheet", function() {
  7051. if (count >= 3800) {
  7052. reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
  7053. }
  7054. });
  7055. }
  7056. });
  7057. CSSLint.addRule({
  7058. id: "selector-max",
  7059. name: "Error when past the 4095 selector limit for IE",
  7060. desc: "Will error when selector count is > 4095.",
  7061. browsers: "IE",
  7062. init: function(parser, reporter) {
  7063. "use strict";
  7064. var rule = this, count = 0;
  7065. parser.addListener("startrule", function(event) {
  7066. count += event.selectors.length;
  7067. });
  7068. parser.addListener("endstylesheet", function() {
  7069. if (count > 4095) {
  7070. reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
  7071. }
  7072. });
  7073. }
  7074. });
  7075. CSSLint.addRule({
  7076. id: "selector-newline",
  7077. name: "Disallow new-line characters in selectors",
  7078. desc: "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.",
  7079. browsers: "All",
  7080. init: function(parser, reporter) {
  7081. "use strict";
  7082. var rule = this;
  7083. function startRule(event) {
  7084. var i, len, selector, p, n, pLen, part, part2, type, currentLine, nextLine,
  7085. selectors = event.selectors;
  7086. for (i = 0, len = selectors.length; i < len; i++) {
  7087. selector = selectors[i];
  7088. for (p = 0, pLen = selector.parts.length; p < pLen; p++) {
  7089. for (n = p + 1; n < pLen; n++) {
  7090. part = selector.parts[p];
  7091. part2 = selector.parts[n];
  7092. type = part.type;
  7093. currentLine = part.line;
  7094. nextLine = part2.line;
  7095. if (type === "descendant" && nextLine > currentLine) {
  7096. reporter.report("newline character found in selector (forgot a comma?)", currentLine, selectors[i].parts[0].col, rule);
  7097. }
  7098. }
  7099. }
  7100. }
  7101. }
  7102. parser.addListener("startrule", startRule);
  7103. }
  7104. });
  7105. CSSLint.addRule({
  7106. id: "shorthand",
  7107. name: "Require shorthand properties",
  7108. desc: "Use shorthand properties where possible.",
  7109. url: "https://github.com/CSSLint/csslint/wiki/Require-shorthand-properties",
  7110. browsers: "All",
  7111. init: function(parser, reporter) {
  7112. "use strict";
  7113. var rule = this,
  7114. prop, i, len,
  7115. propertiesToCheck = {},
  7116. properties,
  7117. mapping = {
  7118. "margin": [
  7119. "margin-top",
  7120. "margin-bottom",
  7121. "margin-left",
  7122. "margin-right"
  7123. ],
  7124. "padding": [
  7125. "padding-top",
  7126. "padding-bottom",
  7127. "padding-left",
  7128. "padding-right"
  7129. ]
  7130. };
  7131. for (prop in mapping) {
  7132. if (mapping.hasOwnProperty(prop)) {
  7133. for (i=0, len=mapping[prop].length; i < len; i++) {
  7134. propertiesToCheck[mapping[prop][i]] = prop;
  7135. }
  7136. }
  7137. }
  7138. function startRule() {
  7139. properties = {};
  7140. }
  7141. function endRule(event) {
  7142. var prop, i, len, total;
  7143. for (prop in mapping) {
  7144. if (mapping.hasOwnProperty(prop)) {
  7145. total=0;
  7146. for (i=0, len=mapping[prop].length; i < len; i++) {
  7147. total += properties[mapping[prop][i]] ? 1 : 0;
  7148. }
  7149. if (total === mapping[prop].length) {
  7150. reporter.report("The properties " + mapping[prop].join(", ") + " can be replaced by " + prop + ".", event.line, event.col, rule);
  7151. }
  7152. }
  7153. }
  7154. }
  7155. parser.addListener("startrule", startRule);
  7156. parser.addListener("startfontface", startRule);
  7157. parser.addListener("property", function(event) {
  7158. var name = event.property.toString().toLowerCase();
  7159. if (propertiesToCheck[name]) {
  7160. properties[name] = 1;
  7161. }
  7162. });
  7163. parser.addListener("endrule", endRule);
  7164. parser.addListener("endfontface", endRule);
  7165. }
  7166. });
  7167. CSSLint.addRule({
  7168. id: "star-property-hack",
  7169. name: "Disallow properties with a star prefix",
  7170. desc: "Checks for the star property hack (targets IE6/7)",
  7171. url: "https://github.com/CSSLint/csslint/wiki/Disallow-star-hack",
  7172. browsers: "All",
  7173. init: function(parser, reporter) {
  7174. "use strict";
  7175. var rule = this;
  7176. parser.addListener("property", function(event) {
  7177. var property = event.property;
  7178. if (property.hack === "*") {
  7179. reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
  7180. }
  7181. });
  7182. }
  7183. });
  7184. CSSLint.addRule({
  7185. id: "text-indent",
  7186. name: "Disallow negative text-indent",
  7187. desc: "Checks for text indent less than -99px",
  7188. url: "https://github.com/CSSLint/csslint/wiki/Disallow-negative-text-indent",
  7189. browsers: "All",
  7190. init: function(parser, reporter) {
  7191. "use strict";
  7192. var rule = this,
  7193. textIndent,
  7194. direction;
  7195. function startRule() {
  7196. textIndent = false;
  7197. direction = "inherit";
  7198. }
  7199. function endRule() {
  7200. if (textIndent && direction !== "ltr") {
  7201. reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
  7202. }
  7203. }
  7204. parser.addListener("startrule", startRule);
  7205. parser.addListener("startfontface", startRule);
  7206. parser.addListener("property", function(event) {
  7207. var name = event.property.toString().toLowerCase(),
  7208. value = event.value;
  7209. if (name === "text-indent" && value.parts[0].value < -99) {
  7210. textIndent = event.property;
  7211. } else if (name === "direction" && value.toString() === "ltr") {
  7212. direction = "ltr";
  7213. }
  7214. });
  7215. parser.addListener("endrule", endRule);
  7216. parser.addListener("endfontface", endRule);
  7217. }
  7218. });
  7219. CSSLint.addRule({
  7220. id: "underscore-property-hack",
  7221. name: "Disallow properties with an underscore prefix",
  7222. desc: "Checks for the underscore property hack (targets IE6)",
  7223. url: "https://github.com/CSSLint/csslint/wiki/Disallow-underscore-hack",
  7224. browsers: "All",
  7225. init: function(parser, reporter) {
  7226. "use strict";
  7227. var rule = this;
  7228. parser.addListener("property", function(event) {
  7229. var property = event.property;
  7230. if (property.hack === "_") {
  7231. reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
  7232. }
  7233. });
  7234. }
  7235. });
  7236. CSSLint.addRule({
  7237. id: "universal-selector",
  7238. name: "Disallow universal selector",
  7239. desc: "The universal selector (*) is known to be slow.",
  7240. url: "https://github.com/CSSLint/csslint/wiki/Disallow-universal-selector",
  7241. browsers: "All",
  7242. init: function(parser, reporter) {
  7243. "use strict";
  7244. var rule = this;
  7245. parser.addListener("startrule", function(event) {
  7246. var selectors = event.selectors,
  7247. selector,
  7248. part,
  7249. i;
  7250. for (i=0; i < selectors.length; i++) {
  7251. selector = selectors[i];
  7252. part = selector.parts[selector.parts.length-1];
  7253. if (part.elementName === "*") {
  7254. reporter.report(rule.desc, part.line, part.col, rule);
  7255. }
  7256. }
  7257. });
  7258. }
  7259. });
  7260. CSSLint.addRule({
  7261. id: "unqualified-attributes",
  7262. name: "Disallow unqualified attribute selectors",
  7263. desc: "Unqualified attribute selectors are known to be slow.",
  7264. url: "https://github.com/CSSLint/csslint/wiki/Disallow-unqualified-attribute-selectors",
  7265. browsers: "All",
  7266. init: function(parser, reporter) {
  7267. "use strict";
  7268. var rule = this;
  7269. parser.addListener("startrule", function(event) {
  7270. var selectors = event.selectors,
  7271. selectorContainsClassOrId = false,
  7272. selector,
  7273. part,
  7274. modifier,
  7275. i, k;
  7276. for (i=0; i < selectors.length; i++) {
  7277. selector = selectors[i];
  7278. part = selector.parts[selector.parts.length-1];
  7279. if (part.type === parser.SELECTOR_PART_TYPE) {
  7280. for (k=0; k < part.modifiers.length; k++) {
  7281. modifier = part.modifiers[k];
  7282. if (modifier.type === "class" || modifier.type === "id") {
  7283. selectorContainsClassOrId = true;
  7284. break;
  7285. }
  7286. }
  7287. if (!selectorContainsClassOrId) {
  7288. for (k=0; k < part.modifiers.length; k++) {
  7289. modifier = part.modifiers[k];
  7290. if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
  7291. reporter.report(rule.desc, part.line, part.col, rule);
  7292. }
  7293. }
  7294. }
  7295. }
  7296. }
  7297. });
  7298. }
  7299. });
  7300. CSSLint.addRule({
  7301. id: "vendor-prefix",
  7302. name: "Require standard property with vendor prefix",
  7303. desc: "When using a vendor-prefixed property, make sure to include the standard one.",
  7304. url: "https://github.com/CSSLint/csslint/wiki/Require-standard-property-with-vendor-prefix",
  7305. browsers: "All",
  7306. init: function(parser, reporter) {
  7307. "use strict";
  7308. var rule = this,
  7309. properties,
  7310. num,
  7311. propertiesToCheck = {
  7312. "-webkit-border-radius": "border-radius",
  7313. "-webkit-border-top-left-radius": "border-top-left-radius",
  7314. "-webkit-border-top-right-radius": "border-top-right-radius",
  7315. "-webkit-border-bottom-left-radius": "border-bottom-left-radius",
  7316. "-webkit-border-bottom-right-radius": "border-bottom-right-radius",
  7317. "-o-border-radius": "border-radius",
  7318. "-o-border-top-left-radius": "border-top-left-radius",
  7319. "-o-border-top-right-radius": "border-top-right-radius",
  7320. "-o-border-bottom-left-radius": "border-bottom-left-radius",
  7321. "-o-border-bottom-right-radius": "border-bottom-right-radius",
  7322. "-moz-border-radius": "border-radius",
  7323. "-moz-border-radius-topleft": "border-top-left-radius",
  7324. "-moz-border-radius-topright": "border-top-right-radius",
  7325. "-moz-border-radius-bottomleft": "border-bottom-left-radius",
  7326. "-moz-border-radius-bottomright": "border-bottom-right-radius",
  7327. "-moz-column-count": "column-count",
  7328. "-webkit-column-count": "column-count",
  7329. "-moz-column-gap": "column-gap",
  7330. "-webkit-column-gap": "column-gap",
  7331. "-moz-column-rule": "column-rule",
  7332. "-webkit-column-rule": "column-rule",
  7333. "-moz-column-rule-style": "column-rule-style",
  7334. "-webkit-column-rule-style": "column-rule-style",
  7335. "-moz-column-rule-color": "column-rule-color",
  7336. "-webkit-column-rule-color": "column-rule-color",
  7337. "-moz-column-rule-width": "column-rule-width",
  7338. "-webkit-column-rule-width": "column-rule-width",
  7339. "-moz-column-width": "column-width",
  7340. "-webkit-column-width": "column-width",
  7341. "-webkit-column-span": "column-span",
  7342. "-webkit-columns": "columns",
  7343. "-moz-box-shadow": "box-shadow",
  7344. "-webkit-box-shadow": "box-shadow",
  7345. "-moz-transform": "transform",
  7346. "-webkit-transform": "transform",
  7347. "-o-transform": "transform",
  7348. "-ms-transform": "transform",
  7349. "-moz-transform-origin": "transform-origin",
  7350. "-webkit-transform-origin": "transform-origin",
  7351. "-o-transform-origin": "transform-origin",
  7352. "-ms-transform-origin": "transform-origin",
  7353. "-moz-box-sizing": "box-sizing",
  7354. "-webkit-box-sizing": "box-sizing"
  7355. };
  7356. function startRule() {
  7357. properties = {};
  7358. num = 1;
  7359. }
  7360. function endRule() {
  7361. var prop,
  7362. i,
  7363. len,
  7364. needed,
  7365. actual,
  7366. needsStandard = [];
  7367. for (prop in properties) {
  7368. if (propertiesToCheck[prop]) {
  7369. needsStandard.push({
  7370. actual: prop,
  7371. needed: propertiesToCheck[prop]
  7372. });
  7373. }
  7374. }
  7375. for (i=0, len=needsStandard.length; i < len; i++) {
  7376. needed = needsStandard[i].needed;
  7377. actual = needsStandard[i].actual;
  7378. if (!properties[needed]) {
  7379. reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
  7380. } else {
  7381. if (properties[needed][0].pos < properties[actual][0].pos) {
  7382. reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
  7383. }
  7384. }
  7385. }
  7386. }
  7387. parser.addListener("startrule", startRule);
  7388. parser.addListener("startfontface", startRule);
  7389. parser.addListener("startpage", startRule);
  7390. parser.addListener("startpagemargin", startRule);
  7391. parser.addListener("startkeyframerule", startRule);
  7392. parser.addListener("startviewport", startRule);
  7393. parser.addListener("property", function(event) {
  7394. var name = event.property.text.toLowerCase();
  7395. if (!properties[name]) {
  7396. properties[name] = [];
  7397. }
  7398. properties[name].push({
  7399. name: event.property,
  7400. value: event.value,
  7401. pos: num++
  7402. });
  7403. });
  7404. parser.addListener("endrule", endRule);
  7405. parser.addListener("endfontface", endRule);
  7406. parser.addListener("endpage", endRule);
  7407. parser.addListener("endpagemargin", endRule);
  7408. parser.addListener("endkeyframerule", endRule);
  7409. parser.addListener("endviewport", endRule);
  7410. }
  7411. });
  7412. CSSLint.addRule({
  7413. id: "zero-units",
  7414. name: "Disallow units for 0 values",
  7415. desc: "You don't need to specify units when a value is 0.",
  7416. url: "https://github.com/CSSLint/csslint/wiki/Disallow-units-for-zero-values",
  7417. browsers: "All",
  7418. init: function(parser, reporter) {
  7419. "use strict";
  7420. var rule = this;
  7421. parser.addListener("property", function(event) {
  7422. var parts = event.value.parts,
  7423. i = 0,
  7424. len = parts.length;
  7425. while (i < len) {
  7426. if ((parts[i].units || parts[i].type === "percentage") && parts[i].value === 0 && parts[i].type !== "time") {
  7427. reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule);
  7428. }
  7429. i++;
  7430. }
  7431. });
  7432. }
  7433. });
  7434. (function() {
  7435. "use strict";
  7436. var xmlEscape = function(str) {
  7437. if (!str || str.constructor !== String) {
  7438. return "";
  7439. }
  7440. return str.replace(/["&><]/g, function(match) {
  7441. switch (match) {
  7442. case "\"":
  7443. return "&quot;";
  7444. case "&":
  7445. return "&amp;";
  7446. case "<":
  7447. return "&lt;";
  7448. case ">":
  7449. return "&gt;";
  7450. }
  7451. });
  7452. };
  7453. CSSLint.addFormatter({
  7454. id: "checkstyle-xml",
  7455. name: "Checkstyle XML format",
  7456. startFormat: function() {
  7457. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
  7458. },
  7459. endFormat: function() {
  7460. return "</checkstyle>";
  7461. },
  7462. readError: function(filename, message) {
  7463. return "<file name=\"" + xmlEscape(filename) + "\"><error line=\"0\" column=\"0\" severty=\"error\" message=\"" + xmlEscape(message) + "\"></error></file>";
  7464. },
  7465. formatResults: function(results, filename/*, options*/) {
  7466. var messages = results.messages,
  7467. output = [];
  7468. var generateSource = function(rule) {
  7469. if (!rule || !("name" in rule)) {
  7470. return "";
  7471. }
  7472. return "net.csslint." + rule.name.replace(/\s/g, "");
  7473. };
  7474. if (messages.length > 0) {
  7475. output.push("<file name=\""+filename+"\">");
  7476. CSSLint.Util.forEach(messages, function (message) {
  7477. if (!message.rollup) {
  7478. output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7479. " message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
  7480. }
  7481. });
  7482. output.push("</file>");
  7483. }
  7484. return output.join("");
  7485. }
  7486. });
  7487. }());
  7488. CSSLint.addFormatter({
  7489. id: "compact",
  7490. name: "Compact, 'porcelain' format",
  7491. startFormat: function() {
  7492. "use strict";
  7493. return "";
  7494. },
  7495. endFormat: function() {
  7496. "use strict";
  7497. return "";
  7498. },
  7499. formatResults: function(results, filename, options) {
  7500. "use strict";
  7501. var messages = results.messages,
  7502. output = "";
  7503. options = options || {};
  7504. var capitalize = function(str) {
  7505. return str.charAt(0).toUpperCase() + str.slice(1);
  7506. };
  7507. if (messages.length === 0) {
  7508. return options.quiet ? "" : filename + ": Lint Free!";
  7509. }
  7510. CSSLint.Util.forEach(messages, function(message) {
  7511. if (message.rollup) {
  7512. output += filename + ": " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
  7513. } else {
  7514. output += filename + ": line " + message.line +
  7515. ", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
  7516. }
  7517. });
  7518. return output;
  7519. }
  7520. });
  7521. CSSLint.addFormatter({
  7522. id: "csslint-xml",
  7523. name: "CSSLint XML format",
  7524. startFormat: function() {
  7525. "use strict";
  7526. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
  7527. },
  7528. endFormat: function() {
  7529. "use strict";
  7530. return "</csslint>";
  7531. },
  7532. formatResults: function(results, filename/*, options*/) {
  7533. "use strict";
  7534. var messages = results.messages,
  7535. output = [];
  7536. var escapeSpecialCharacters = function(str) {
  7537. if (!str || str.constructor !== String) {
  7538. return "";
  7539. }
  7540. return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7541. };
  7542. if (messages.length > 0) {
  7543. output.push("<file name=\""+filename+"\">");
  7544. CSSLint.Util.forEach(messages, function (message) {
  7545. if (message.rollup) {
  7546. output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7547. } else {
  7548. output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7549. " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7550. }
  7551. });
  7552. output.push("</file>");
  7553. }
  7554. return output.join("");
  7555. }
  7556. });
  7557. CSSLint.addFormatter({
  7558. id: "json",
  7559. name: "JSON",
  7560. startFormat: function() {
  7561. "use strict";
  7562. this.json = [];
  7563. return "";
  7564. },
  7565. endFormat: function() {
  7566. "use strict";
  7567. var ret = "";
  7568. if (this.json.length > 0) {
  7569. if (this.json.length === 1) {
  7570. ret = JSON.stringify(this.json[0]);
  7571. } else {
  7572. ret = JSON.stringify(this.json);
  7573. }
  7574. }
  7575. return ret;
  7576. },
  7577. formatResults: function(results, filename, options) {
  7578. "use strict";
  7579. if (results.messages.length > 0 || !options.quiet) {
  7580. this.json.push({
  7581. filename: filename,
  7582. messages: results.messages,
  7583. stats: results.stats
  7584. });
  7585. }
  7586. return "";
  7587. }
  7588. });
  7589. CSSLint.addFormatter({
  7590. id: "junit-xml",
  7591. name: "JUNIT XML format",
  7592. startFormat: function() {
  7593. "use strict";
  7594. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
  7595. },
  7596. endFormat: function() {
  7597. "use strict";
  7598. return "</testsuites>";
  7599. },
  7600. formatResults: function(results, filename/*, options*/) {
  7601. "use strict";
  7602. var messages = results.messages,
  7603. output = [],
  7604. tests = {
  7605. "error": 0,
  7606. "failure": 0
  7607. };
  7608. var generateSource = function(rule) {
  7609. if (!rule || !("name" in rule)) {
  7610. return "";
  7611. }
  7612. return "net.csslint." + rule.name.replace(/\s/g, "");
  7613. };
  7614. var escapeSpecialCharacters = function(str) {
  7615. if (!str || str.constructor !== String) {
  7616. return "";
  7617. }
  7618. return str.replace(/"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7619. };
  7620. if (messages.length > 0) {
  7621. messages.forEach(function (message) {
  7622. var type = message.type === "warning" ? "error" : message.type;
  7623. if (!message.rollup) {
  7624. output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
  7625. output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ":" + message.col + ":" + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
  7626. output.push("</testcase>");
  7627. tests[type] += 1;
  7628. }
  7629. });
  7630. output.unshift("<testsuite time=\"0\" tests=\"" + messages.length + "\" skipped=\"0\" errors=\"" + tests.error + "\" failures=\"" + tests.failure + "\" package=\"net.csslint\" name=\"" + filename + "\">");
  7631. output.push("</testsuite>");
  7632. }
  7633. return output.join("");
  7634. }
  7635. });
  7636. CSSLint.addFormatter({
  7637. id: "lint-xml",
  7638. name: "Lint XML format",
  7639. startFormat: function() {
  7640. "use strict";
  7641. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
  7642. },
  7643. endFormat: function() {
  7644. "use strict";
  7645. return "</lint>";
  7646. },
  7647. formatResults: function(results, filename/*, options*/) {
  7648. "use strict";
  7649. var messages = results.messages,
  7650. output = [];
  7651. var escapeSpecialCharacters = function(str) {
  7652. if (!str || str.constructor !== String) {
  7653. return "";
  7654. }
  7655. return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7656. };
  7657. if (messages.length > 0) {
  7658. output.push("<file name=\""+filename+"\">");
  7659. CSSLint.Util.forEach(messages, function (message) {
  7660. if (message.rollup) {
  7661. output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7662. } else {
  7663. var rule = "";
  7664. if (message.rule && message.rule.id) {
  7665. rule = "rule=\"" + escapeSpecialCharacters(message.rule.id) + "\" ";
  7666. }
  7667. output.push("<issue " + rule + "line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7668. " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7669. }
  7670. });
  7671. output.push("</file>");
  7672. }
  7673. return output.join("");
  7674. }
  7675. });
  7676. CSSLint.addFormatter({
  7677. id: "text",
  7678. name: "Plain Text",
  7679. startFormat: function() {
  7680. "use strict";
  7681. return "";
  7682. },
  7683. endFormat: function() {
  7684. "use strict";
  7685. return "";
  7686. },
  7687. formatResults: function(results, filename, options) {
  7688. "use strict";
  7689. var messages = results.messages,
  7690. output = "";
  7691. options = options || {};
  7692. if (messages.length === 0) {
  7693. return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
  7694. }
  7695. output = "\n\ncsslint: There ";
  7696. if (messages.length === 1) {
  7697. output += "is 1 problem";
  7698. } else {
  7699. output += "are " + messages.length + " problems";
  7700. }
  7701. output += " in " + filename + ".";
  7702. var pos = filename.lastIndexOf("/"),
  7703. shortFilename = filename;
  7704. if (pos === -1) {
  7705. pos = filename.lastIndexOf("\\");
  7706. }
  7707. if (pos > -1) {
  7708. shortFilename = filename.substring(pos+1);
  7709. }
  7710. CSSLint.Util.forEach(messages, function (message, i) {
  7711. output = output + "\n\n" + shortFilename;
  7712. if (message.rollup) {
  7713. output += "\n" + (i+1) + ": " + message.type;
  7714. output += "\n" + message.message;
  7715. } else {
  7716. output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col;
  7717. output += "\n" + message.message;
  7718. output += "\n" + message.evidence;
  7719. }
  7720. });
  7721. return output;
  7722. }
  7723. });
  7724. return CSSLint;
  7725. })();
  7726. module.exports.CSSLint = CSSLint;
  7727. });
  7728. ace.define("ace/mode/css_worker",[], function(require, exports, module) {
  7729. "use strict";
  7730. var oop = require("../lib/oop");
  7731. var lang = require("../lib/lang");
  7732. var Mirror = require("../worker/mirror").Mirror;
  7733. var CSSLint = require("./css/csslint").CSSLint;
  7734. var Worker = exports.Worker = function(sender) {
  7735. Mirror.call(this, sender);
  7736. this.setTimeout(400);
  7737. this.ruleset = null;
  7738. this.setDisabledRules("ids|order-alphabetical");
  7739. this.setInfoRules(
  7740. "adjoining-classes|zero-units|gradients|box-model|" +
  7741. "import|outline-none|vendor-prefix"
  7742. );
  7743. };
  7744. oop.inherits(Worker, Mirror);
  7745. (function() {
  7746. this.setInfoRules = function(ruleNames) {
  7747. if (typeof ruleNames == "string")
  7748. ruleNames = ruleNames.split("|");
  7749. this.infoRules = lang.arrayToMap(ruleNames);
  7750. this.doc.getValue() && this.deferredUpdate.schedule(100);
  7751. };
  7752. this.setDisabledRules = function(ruleNames) {
  7753. if (!ruleNames) {
  7754. this.ruleset = null;
  7755. } else {
  7756. if (typeof ruleNames == "string")
  7757. ruleNames = ruleNames.split("|");
  7758. var all = {};
  7759. CSSLint.getRules().forEach(function(x){
  7760. all[x.id] = true;
  7761. });
  7762. ruleNames.forEach(function(x) {
  7763. delete all[x];
  7764. });
  7765. this.ruleset = all;
  7766. }
  7767. this.doc.getValue() && this.deferredUpdate.schedule(100);
  7768. };
  7769. this.onUpdate = function() {
  7770. var value = this.doc.getValue();
  7771. if (!value)
  7772. return this.sender.emit("annotate", []);
  7773. var infoRules = this.infoRules;
  7774. var result = CSSLint.verify(value, this.ruleset);
  7775. this.sender.emit("annotate", result.messages.map(function(msg) {
  7776. return {
  7777. row: msg.line - 1,
  7778. column: msg.col - 1,
  7779. text: msg.message,
  7780. type: infoRules[msg.rule.id] ? "info" : msg.type,
  7781. rule: msg.rule.name
  7782. };
  7783. }));
  7784. };
  7785. }).call(Worker.prototype);
  7786. });