From 0d471bf64ac13ff37c8d522235a02f16829e80c7 Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Fri, 10 May 2002 22:05:59 +0000 Subject: [PATCH] Add 'View Selection/MathML Source' to the context menu & the support for that to work, namely: enlist MathML entity names, break viewSource.xul into a sharable XUL overlay, and implement the necessary logic to automatically re-select a selection into the inflated view-source display. b=49721,1222524, r=bzbarsky, sr=alecf git-svn-id: svn://10.0.0.236/trunk@121297 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/embedding/config/basebrowser-mac-cfm | 6 +- .../embedding/config/basebrowser-mac-cfmDebug | 6 +- mozilla/embedding/config/basebrowser-win | 6 +- .../unicharutil/idl/nsIEntityConverter.idl | 3 +- mozilla/intl/unicharutil/tables/Makefile.in | 4 + .../tables/htmlEntityVersions.properties | 3 +- mozilla/intl/unicharutil/tables/makefile.win | 5 + .../unicharutil/tables/mathml20.properties | 1247 +++++++++++++++++ mozilla/xpfe/browser/jar.mn | 3 + .../resources/content/viewPartialSource.js | 478 +++++++ .../resources/content/viewPartialSource.xul | 82 ++ .../browser/resources/content/viewSource.xul | 158 +-- .../resources/content/viewSourceOverlay.xul | 172 +++ .../content/contentAreaContextOverlay.xul | 8 + .../resources/content/nsContextMenu.js | 37 + .../locale/en-US/contentAreaCommands.dtd | 3 + 16 files changed, 2077 insertions(+), 144 deletions(-) create mode 100644 mozilla/intl/unicharutil/tables/mathml20.properties create mode 100644 mozilla/xpfe/browser/resources/content/viewPartialSource.js create mode 100644 mozilla/xpfe/browser/resources/content/viewPartialSource.xul create mode 100644 mozilla/xpfe/browser/resources/content/viewSourceOverlay.xul diff --git a/mozilla/embedding/config/basebrowser-mac-cfm b/mozilla/embedding/config/basebrowser-mac-cfm index 98a38a7253d..e160a5c5a4c 100644 --- a/mozilla/embedding/config/basebrowser-mac-cfm +++ b/mozilla/embedding/config/basebrowser-mac-cfm @@ -275,11 +275,7 @@ res:loading-image.gif res:broken-image.gif res:builtin:htmlBindings.xml res:builtin:platformHTMLBindings.xml -res:entityTables:html40Latin1.properties -res:entityTables:html40Special.properties -res:entityTables:html40Symbols.properties -res:entityTables:htmlEntityVersions.properties -res:entityTables:transliterate.properties +res:entityTables:* res:fonts:* ; diff --git a/mozilla/embedding/config/basebrowser-mac-cfmDebug b/mozilla/embedding/config/basebrowser-mac-cfmDebug index d0e71c71776..7e32fec8dd6 100644 --- a/mozilla/embedding/config/basebrowser-mac-cfmDebug +++ b/mozilla/embedding/config/basebrowser-mac-cfmDebug @@ -275,11 +275,7 @@ res:loading-image.gif res:broken-image.gif res:builtin:htmlBindings.xml res:builtin:platformHTMLBindings.xml -res:entityTables:html40Latin1.properties -res:entityTables:html40Special.properties -res:entityTables:html40Symbols.properties -res:entityTables:htmlEntityVersions.properties -res:entityTables:transliterate.properties +res:entityTables:* res:fonts:* ; diff --git a/mozilla/embedding/config/basebrowser-win b/mozilla/embedding/config/basebrowser-win index ef9fa7765ef..b379177a912 100644 --- a/mozilla/embedding/config/basebrowser-win +++ b/mozilla/embedding/config/basebrowser-win @@ -296,11 +296,7 @@ res\loading-image.gif res\broken-image.gif res\builtin\htmlBindings.xml res\builtin\platformHTMLBindings.xml -res\entityTables\html40Latin1.properties -res\entityTables\html40Special.properties -res\entityTables\html40Symbols.properties -res\entityTables\htmlEntityVersions.properties -res\entityTables\transliterate.properties +res\entityTables\* res\fonts\* ; diff --git a/mozilla/intl/unicharutil/idl/nsIEntityConverter.idl b/mozilla/intl/unicharutil/idl/nsIEntityConverter.idl index ae65ca5151c..d360ae5b85b 100644 --- a/mozilla/intl/unicharutil/idl/nsIEntityConverter.idl +++ b/mozilla/intl/unicharutil/idl/nsIEntityConverter.idl @@ -52,10 +52,11 @@ interface nsIEntityConverter : nsISupports const unsigned long html40Symbols = 2; const unsigned long html40Special = 4; // excludes ", &, <, > const unsigned long transliterate = 8; + const unsigned long mathml20 = 16; const unsigned long html32 = html40Latin1; const unsigned long html40 = html40Latin1+html40Symbols+html40Special; - string ConvertToEntity(in wchar character, in unsigned long entityVersion); + string ConvertToEntity(in wchar character, in unsigned long entityVersion); wstring ConvertToEntities(in wstring inString, in unsigned long entityVersion); }; diff --git a/mozilla/intl/unicharutil/tables/Makefile.in b/mozilla/intl/unicharutil/tables/Makefile.in index a34d5475a1f..3a5a9588935 100644 --- a/mozilla/intl/unicharutil/tables/Makefile.in +++ b/mozilla/intl/unicharutil/tables/Makefile.in @@ -36,6 +36,10 @@ _PROP_TABLES = \ transliterate.properties \ $(NULL) +ifdef MOZ_MATHML +_PROP_TABLES += mathml20.properties +endif + libs:: $(_PROP_TABLES) $(INSTALL) $^ $(DIST)/bin/res/entityTables diff --git a/mozilla/intl/unicharutil/tables/htmlEntityVersions.properties b/mozilla/intl/unicharutil/tables/htmlEntityVersions.properties index 3752b23592e..e6f525e7a00 100644 --- a/mozilla/intl/unicharutil/tables/htmlEntityVersions.properties +++ b/mozilla/intl/unicharutil/tables/htmlEntityVersions.properties @@ -25,8 +25,9 @@ # list supported versions number/name pair # length should not be greater than 32 -length=4 +length=5 1=html40Latin1 2=html40Symbols 3=html40Special 4=transliterate +5=mathml20 diff --git a/mozilla/intl/unicharutil/tables/makefile.win b/mozilla/intl/unicharutil/tables/makefile.win index ab3c42ded9d..165c9f9b17b 100644 --- a/mozilla/intl/unicharutil/tables/makefile.win +++ b/mozilla/intl/unicharutil/tables/makefile.win @@ -34,6 +34,11 @@ libs:: $(MAKE_INSTALL) .\html40Special.properties $(DIST)\bin\res\entityTables $(MAKE_INSTALL) .\transliterate.properties $(DIST)\bin\res\entityTables +!ifdef MOZ_MATHML +libs:: + $(MAKE_INSTALL) .\mathml20.properties $(DIST)\bin\res\entityTables +!endif + clobber:: rm -fr $(DIST)\res diff --git a/mozilla/intl/unicharutil/tables/mathml20.properties b/mozilla/intl/unicharutil/tables/mathml20.properties new file mode 100644 index 00000000000..2c474ebdb8c --- /dev/null +++ b/mozilla/intl/unicharutil/tables/mathml20.properties @@ -0,0 +1,1247 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Mozilla MathML Project. +# +# The Initial Developer of the Original Code is +# The University Of Queensland. +# Portions created by the Initial Developer are Copyright (C) 2002 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Roger B. Sidje +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +## LOCALIZATION NOTE: FILE +# Do not translate this file. +# The file contains a mapping of Unicode values to MathML entity names. +# Entities already listed in html40 were deliberately excluded. So you must use +# nsIEntityConverter.html40 + nsIEntityConverter.mathml20 to access everything. + +entity.list.name=mathml20 +entity.256=Ā +entity.257=ā +entity.258=Ă +entity.259=ă +entity.260=Ą +entity.261=ą +entity.262=Ć +entity.263=ć +entity.264=Ĉ +entity.265=ĉ +entity.266=Ċ +entity.267=ċ +entity.268=Č +entity.269=č +entity.270=Ď +entity.271=ď +entity.272=Đ +entity.273=đ +entity.274=Ē +entity.275=ē +entity.278=Ė +entity.279=ė +entity.280=Ę +entity.281=ę +entity.282=Ě +entity.283=ě +entity.284=Ĝ +entity.285=ĝ +entity.286=Ğ +entity.287=ğ +entity.288=Ġ +entity.289=ġ +entity.290=Ģ +entity.292=Ĥ +entity.293=ĥ +entity.294=Ħ +entity.295=ħ +entity.296=Ĩ +entity.297=ĩ +entity.298=Ī +entity.299=ī +entity.302=Į +entity.303=į +entity.304=İ +entity.305=ı +entity.306=IJ +entity.307=ij +entity.308=Ĵ +entity.309=ĵ +entity.310=Ķ +entity.311=ķ +entity.312=ĸ +entity.313=Ĺ +entity.314=ĺ +entity.315=Ļ +entity.316=ļ +entity.317=Ľ +entity.318=ľ +entity.319=Ŀ +entity.320=ŀ +entity.321=Ł +entity.322=ł +entity.323=Ń +entity.324=ń +entity.325=Ņ +entity.326=ņ +entity.327=Ň +entity.328=ň +entity.329=ʼn +entity.330=Ŋ +entity.331=ŋ +entity.332=Ō +entity.333=ō +entity.336=Ő +entity.337=ő +entity.340=Ŕ +entity.341=ŕ +entity.342=Ŗ +entity.343=ŗ +entity.344=Ř +entity.345=ř +entity.346=Ś +entity.347=ś +entity.348=Ŝ +entity.349=ŝ +entity.350=Ş +entity.351=ş +entity.354=Ţ +entity.355=ţ +entity.356=Ť +entity.357=ť +entity.358=Ŧ +entity.359=ŧ +entity.360=Ũ +entity.361=ũ +entity.362=Ū +entity.363=ū +entity.364=Ŭ +entity.365=ŭ +entity.366=Ů +entity.367=ů +entity.368=Ű +entity.369=ű +entity.370=Ų +entity.371=ų +entity.372=Ŵ +entity.373=ŵ +entity.374=Ŷ +entity.375=ŷ +entity.377=Ź +entity.378=ź +entity.379=Ż +entity.380=ż +entity.381=Ž +entity.382=ž +entity.501=ǵ +entity.603=ϵ +entity.711=ˇ +entity.728=˘ +entity.729=˙ +entity.730=˚ +entity.731=˛ +entity.733=˝ +entity.770=^ +entity.785=̑ +entity.818=_ +entity.981=ϕ +entity.988=Ϝ +entity.1008=ϰ +entity.1009=ϱ +entity.1014=϶ +entity.1025=Ё +entity.1026=Ђ +entity.1027=Ѓ +entity.1028=Є +entity.1029=Ѕ +entity.1030=І +entity.1031=Ї +entity.1032=Ј +entity.1033=Љ +entity.1034=Њ +entity.1035=Ћ +entity.1036=Ќ +entity.1038=Ў +entity.1039=Џ +entity.1040=А +entity.1041=Б +entity.1042=В +entity.1043=Г +entity.1044=Д +entity.1045=Е +entity.1046=Ж +entity.1047=З +entity.1048=И +entity.1049=Й +entity.1050=К +entity.1051=Л +entity.1052=М +entity.1053=Н +entity.1054=О +entity.1055=П +entity.1056=Р +entity.1057=С +entity.1058=Т +entity.1059=У +entity.1060=Ф +entity.1061=Х +entity.1062=Ц +entity.1063=Ч +entity.1064=Ш +entity.1065=Щ +entity.1066=Ъ +entity.1067=Ы +entity.1068=Ь +entity.1069=Э +entity.1070=Ю +entity.1071=Я +entity.1072=а +entity.1073=б +entity.1074=в +entity.1075=г +entity.1076=д +entity.1077=е +entity.1078=ж +entity.1079=з +entity.1080=и +entity.1081=й +entity.1082=к +entity.1083=л +entity.1084=м +entity.1085=н +entity.1086=о +entity.1087=п +entity.1088=р +entity.1089=с +entity.1090=т +entity.1091=у +entity.1092=ф +entity.1093=х +entity.1094=ц +entity.1095=ч +entity.1096=ш +entity.1097=щ +entity.1098=ъ +entity.1099=ы +entity.1100=ь +entity.1101=э +entity.1102=ю +entity.1103=я +entity.1105=ё +entity.1106=ђ +entity.1107=ѓ +entity.1108=є +entity.1109=ѕ +entity.1110=і +entity.1111=ї +entity.1112=ј +entity.1113=љ +entity.1114=њ +entity.1115=ћ +entity.1116=ќ +entity.1118=ў +entity.1119=џ +entity.8196=  +entity.8197=  +entity.8199=  +entity.8200=  +entity.8202=  +entity.8203=⁣ +entity.8208=‐ +entity.8213=― +entity.8214=‖ +entity.8229=‥ +entity.8241=‱ +entity.8244=‴ +entity.8245=‵ +entity.8257=⁁ +entity.8259=⁃ +entity.8271=⁏ +entity.8279=⁗ +entity.8287=  +entity.8289=⁡ +entity.8290=⁢ +entity.8411=⃛ +entity.8412=⃜ +entity.8450=ℂ +entity.8453=℅ +entity.8458=ℊ +entity.8459=ℋ +entity.8460=ℌ +entity.8461=ℍ +entity.8462=ℎ +entity.8463=ℏ +entity.8464=ℐ +entity.8466=ℒ +entity.8467=𝓁 +entity.8469=ℕ +entity.8470=№ +entity.8471=℗ +entity.8473=ℙ +entity.8474=ℚ +entity.8475=ℛ +entity.8477=ℝ +entity.8478=℞ +entity.8484=ℤ +entity.8486=Ω +entity.8487=℧ +entity.8488=ℨ +entity.8489=℩ +entity.8491=Å +entity.8492=ℬ +entity.8493=ℭ +entity.8495=ℯ +entity.8496=ℰ +entity.8497=ℱ +entity.8499=ℳ +entity.8500=ℴ +entity.8502=ℶ +entity.8503=ℷ +entity.8504=ℸ +entity.8517=ⅅ +entity.8518=ⅆ +entity.8519=ⅇ +entity.8520=ⅈ +entity.8531=⅓ +entity.8532=⅔ +entity.8533=⅕ +entity.8534=⅖ +entity.8535=⅗ +entity.8536=⅘ +entity.8537=⅙ +entity.8538=⅚ +entity.8539=⅛ +entity.8540=⅜ +entity.8541=⅝ +entity.8542=⅞ +entity.8597=↕ +entity.8598=↖ +entity.8599=↗ +entity.8600=↘ +entity.8601=↙ +entity.8602=↚ +entity.8603=↛ +entity.8605=↝ +entity.8606=↞ +entity.8607=↟ +entity.8608=↠ +entity.8609=↡ +entity.8610=↢ +entity.8611=↣ +entity.8612=↤ +entity.8613=↥ +entity.8614=↦ +entity.8615=↧ +entity.8617=↩ +entity.8618=↪ +entity.8619=↫ +entity.8620=↬ +entity.8621=↭ +entity.8622=↮ +entity.8624=↰ +entity.8625=↱ +entity.8626=↲ +entity.8627=↳ +entity.8630=↶ +entity.8631=↷ +entity.8634=↺ +entity.8635=↻ +entity.8636=↼ +entity.8637=↽ +entity.8638=↾ +entity.8639=↿ +entity.8640=⇀ +entity.8641=⇁ +entity.8642=⇂ +entity.8643=⇃ +entity.8644=⇄ +entity.8645=⇅ +entity.8646=⇆ +entity.8647=⇇ +entity.8648=⇈ +entity.8649=⇉ +entity.8650=⇊ +entity.8651=⇋ +entity.8652=⇌ +entity.8653=⇍ +entity.8654=⇎ +entity.8655=⇏ +entity.8661=⇕ +entity.8662=⇖ +entity.8663=⇗ +entity.8664=⇘ +entity.8665=⇙ +entity.8666=⇚ +entity.8667=⇛ +entity.8669=⇝ +entity.8676=⇤ +entity.8677=⇥ +entity.8693=⇵ +entity.8701=⇽ +entity.8702=⇾ +entity.8703=⇿ +entity.8705=∁ +entity.8708=∄ +entity.8716=∌ +entity.8720=∐ +entity.8723=∓ +entity.8724=∔ +entity.8726=∖ +entity.8728=∘ +entity.8735=∟ +entity.8737=∡ +entity.8738=∢ +entity.8739=∣ +entity.8740=∤ +entity.8741=∥ +entity.8742=∦ +entity.8748=∬ +entity.8749=∭ +entity.8750=∮ +entity.8751=∯ +entity.8752=∰ +entity.8753=∱ +entity.8754=∲ +entity.8755=∳ +entity.8757=∵ +entity.8758=∶ +entity.8759=∷ +entity.8760=∸ +entity.8762=∺ +entity.8763=∻ +entity.8765=∽ +entity.8766=∾ +entity.8767=∿ +entity.8768=≀ +entity.8769=≁ +entity.8770=≂ +entity.8771=≃ +entity.8772=≄ +entity.8774=≆ +entity.8775=≇ +entity.8777=≉ +entity.8778=≊ +entity.8779=≋ +entity.8780=≌ +entity.8781=≍ +entity.8782=≎ +entity.8783=≏ +entity.8784=≐ +entity.8785=≑ +entity.8786=≒ +entity.8787=≓ +entity.8788=≔ +entity.8789=≕ +entity.8790=≖ +entity.8791=≗ +entity.8793=≙ +entity.8794=≚ +entity.8795=⩮ +entity.8796=≜ +entity.8799=≟ +entity.8802=≢ +entity.8806=≦ +entity.8807=≧ +entity.8808=≨ +entity.8809=≩ +entity.8810=≪ +entity.8811=≫ +entity.8812=≬ +entity.8813=≭ +entity.8814=≮ +entity.8815=≯ +entity.8816=≧̸ +entity.8817=⩾̸ +entity.8818=≲ +entity.8819=≳ +entity.8820=≴ +entity.8821=≵ +entity.8822=≶ +entity.8823=≷ +entity.8824=≸ +entity.8825=≹ +entity.8826=≺ +entity.8827=≻ +entity.8828=≼ +entity.8829=≽ +entity.8830=≾ +entity.8831=≿ +entity.8832=⊀ +entity.8833=⊁ +entity.8837=⊃⃒ +entity.8840=⊈ +entity.8841=⊉ +entity.8842=⫋ +entity.8843=⫌ +entity.8845=⊍ +entity.8846=⊎ +entity.8847=⊏ +entity.8848=⊐ +entity.8849=⊑ +entity.8850=⊒ +entity.8851=⊓ +entity.8852=⊔ +entity.8854=⊖ +entity.8856=⊘ +entity.8857=⊙ +entity.8858=⊚ +entity.8859=⊛ +entity.8861=⊝ +entity.8862=⊞ +entity.8863=⊟ +entity.8864=⊠ +entity.8865=⊡ +entity.8866=⊢ +entity.8867=⊣ +entity.8868=⊤ +entity.8871=⊧ +entity.8872=⊨ +entity.8873=⊩ +entity.8874=⊪ +entity.8875=⊫ +entity.8876=⊬ +entity.8877=⊭ +entity.8878=⊮ +entity.8879=⊯ +entity.8880=⊰ +entity.8882=⊲ +entity.8883=⊳ +entity.8884=⊴ +entity.8885=⊵ +entity.8886=⊶ +entity.8887=⊷ +entity.8888=⊸ +entity.8889=⊹ +entity.8890=⊺ +entity.8891=⊻ +entity.8892=⌅ +entity.8893=⊽ +entity.8894=⦜ +entity.8895=⊿ +entity.8896=⋀ +entity.8897=⋁ +entity.8898=⋂ +entity.8899=⋃ +entity.8900=⋄ +entity.8902=⋆ +entity.8903=⋇ +entity.8904=⋈ +entity.8905=⋉ +entity.8906=⋊ +entity.8907=⋋ +entity.8908=⋌ +entity.8909=⋍ +entity.8910=⋎ +entity.8911=⋏ +entity.8912=⋐ +entity.8913=⋑ +entity.8914=⋒ +entity.8915=⋓ +entity.8916=⋔ +entity.8917=⋕ +entity.8918=⋖ +entity.8919=⋗ +entity.8920=⋘ +entity.8921=⋙ +entity.8922=⋚ +entity.8923=⋛ +entity.8924=⪕ +entity.8925=⪖ +entity.8926=⋞ +entity.8927=⋟ +entity.8928=⋠ +entity.8929=⋡ +entity.8930=⋢ +entity.8931=⋣ +entity.8934=⋦ +entity.8935=⋧ +entity.8936=⪹ +entity.8937=⪺ +entity.8938=⋪ +entity.8939=⋫ +entity.8940=⋬ +entity.8941=⋭ +entity.8942=⋮ +entity.8943=⋯ +entity.8944=⋰ +entity.8945=⋱ +entity.8946=⋲ +entity.8947=⋳ +entity.8948=⋴ +entity.8949=⋵ +entity.8950=⋶ +entity.8951=⋷ +entity.8953=⋹ +entity.8954=⋺ +entity.8955=⋻ +entity.8956=⋼ +entity.8957=⋽ +entity.8958=⋾ +entity.8966=⌆ +entity.8972=⌌ +entity.8973=⌍ +entity.8974=⌎ +entity.8975=⌏ +entity.8976=⌐ +entity.8978=⌒ +entity.8979=⌓ +entity.8981=⌕ +entity.8982=⌖ +entity.8988=⌜ +entity.8989=⌝ +entity.8990=⌞ +entity.8991=⌟ +entity.8994=⌢ +entity.8995=⌣ +entity.9005=⌭ +entity.9006=⌮ +entity.9014=⌶ +entity.9021=⌽ +entity.9023=⌿ +entity.9084=⍼ +entity.9136=⎰ +entity.9137=⎱ +entity.9140=⎴ +entity.9141=⎵ +entity.9251=␣ +entity.9416=Ⓢ +entity.9472=─ +entity.9474=│ +entity.9484=┌ +entity.9488=┐ +entity.9492=└ +entity.9496=┘ +entity.9500=├ +entity.9508=┤ +entity.9516=┬ +entity.9524=┴ +entity.9532=┼ +entity.9552=═ +entity.9553=║ +entity.9554=╒ +entity.9555=╓ +entity.9556=╔ +entity.9557=╕ +entity.9558=╖ +entity.9559=╗ +entity.9560=╘ +entity.9561=╙ +entity.9562=╚ +entity.9563=╛ +entity.9564=╜ +entity.9565=╝ +entity.9566=╞ +entity.9567=╟ +entity.9568=╠ +entity.9569=╡ +entity.9570=╢ +entity.9571=╣ +entity.9572=╤ +entity.9573=╥ +entity.9574=╦ +entity.9575=╧ +entity.9576=╨ +entity.9577=╩ +entity.9578=╪ +entity.9579=╫ +entity.9580=╬ +entity.9600=▀ +entity.9604=▄ +entity.9608=█ +entity.9617=░ +entity.9618=▒ +entity.9619=▓ +entity.9633=□ +entity.9642=▪ +entity.9645=▭ +entity.9646=▮ +entity.9651=△ +entity.9652=▴ +entity.9653=▵ +entity.9656=▸ +entity.9657=▹ +entity.9661=▽ +entity.9662=▾ +entity.9663=▿ +entity.9666=◂ +entity.9667=◃ +entity.9675=○ +entity.9708=◬ +entity.9711=◯ +entity.9720=◸ +entity.9721=◹ +entity.9722=◺ +entity.9725=◻ +entity.9726=◼ +entity.9733=★ +entity.9742=☎ +entity.9792=♀ +entity.9794=♂ +entity.9825=♥ +entity.9834=♪ +entity.9837=♭ +entity.9838=♮ +entity.9839=♯ +entity.10003=✓ +entity.10007=✗ +entity.10016=✠ +entity.10038=✶ +entity.10072=❘ +entity.10501=⤅ +entity.10508=⤌ +entity.10509=⤍ +entity.10510=⤎ +entity.10511=⤏ +entity.10512=⤐ +entity.10513=⤑ +entity.10514=⤒ +entity.10515=⤓ +entity.10518=⤖ +entity.10521=⤙ +entity.10523=⤛ +entity.10524=⤜ +entity.10525=⤝ +entity.10526=⤞ +entity.10527=⤟ +entity.10528=⤠ +entity.10531=⤣ +entity.10532=⤤ +entity.10533=⤥ +entity.10534=⤦ +entity.10535=⤧ +entity.10536=⤨ +entity.10537=⤩ +entity.10538=⤪ +entity.10547=⤳ +entity.10549=⤵ +entity.10550=⤶ +entity.10551=⤷ +entity.10552=⤸ +entity.10553=⤹ +entity.10556=⤼ +entity.10557=⤽ +entity.10565=⥅ +entity.10568=⥈ +entity.10569=⥉ +entity.10570=⥊ +entity.10571=⥋ +entity.10574=⥎ +entity.10575=⥏ +entity.10576=⥐ +entity.10577=⥑ +entity.10578=⥒ +entity.10579=⥓ +entity.10580=⥔ +entity.10581=⥕ +entity.10582=⥖ +entity.10583=⥗ +entity.10584=⥘ +entity.10585=⥙ +entity.10586=⥚ +entity.10587=⥛ +entity.10588=⥜ +entity.10589=⥝ +entity.10590=⥞ +entity.10591=⥟ +entity.10592=⥠ +entity.10593=⥡ +entity.10594=⥢ +entity.10595=⥣ +entity.10596=⥤ +entity.10597=⥥ +entity.10598=⥦ +entity.10599=⥧ +entity.10600=⥨ +entity.10601=⥩ +entity.10602=⥪ +entity.10603=⥫ +entity.10604=⥬ +entity.10605=⥭ +entity.10606=⥮ +entity.10607=⥯ +entity.10608=⥰ +entity.10609=⥱ +entity.10610=⥲ +entity.10611=⥳ +entity.10612=⥴ +entity.10613=⥵ +entity.10614=⥶ +entity.10616=⥸ +entity.10617=⥹ +entity.10619=⥻ +entity.10620=⥼ +entity.10621=⥽ +entity.10622=⥾ +entity.10623=⥿ +entity.10635=⦋ +entity.10636=⦌ +entity.10637=⦍ +entity.10638=⦎ +entity.10639=⦏ +entity.10640=⦐ +entity.10641=⦑ +entity.10642=⦒ +entity.10643=⦓ +entity.10644=⦔ +entity.10645=⦕ +entity.10646=⦖ +entity.10650=⦚ +entity.10653=⦝ +entity.10660=⦤ +entity.10661=⦥ +entity.10662=⦦ +entity.10663=⦧ +entity.10664=⦨ +entity.10665=⦩ +entity.10666=⦪ +entity.10667=⦫ +entity.10668=⦬ +entity.10669=⦭ +entity.10670=⦮ +entity.10671=⦯ +entity.10672=⦰ +entity.10673=⦱ +entity.10674=⦲ +entity.10675=⦳ +entity.10676=⦴ +entity.10677=⦵ +entity.10678=⦶ +entity.10679=⦷ +entity.10681=⦹ +entity.10683=⦻ +entity.10684=⦼ +entity.10686=⦾ +entity.10687=⦿ +entity.10688=⧀ +entity.10689=⧁ +entity.10690=⧂ +entity.10691=⧃ +entity.10692=⧄ +entity.10693=⧅ +entity.10697=⧉ +entity.10701=⧍ +entity.10702=⧎ +entity.10703=⧏ +entity.10704=⧐ +entity.10714=∽̱ +entity.10715=∾̳ +entity.10716=⧜ +entity.10718=⧞ +entity.10723=⧣ +entity.10724=⧤ +entity.10725=⧥ +entity.10731=⧫ +entity.10740=⧴ +entity.10742=⧶ +entity.10764=⨌ +entity.10765=⨍ +entity.10768=⨐ +entity.10769=⨑ +entity.10770=⨒ +entity.10771=⨓ +entity.10772=⨔ +entity.10773=⨕ +entity.10774=⨖ +entity.10775=⨗ +entity.10786=⨢ +entity.10787=⨣ +entity.10788=⨤ +entity.10789=⨥ +entity.10790=⨦ +entity.10791=⨧ +entity.10793=⨩ +entity.10794=⨪ +entity.10797=⨭ +entity.10798=⨮ +entity.10799=⨯ +entity.10800=⨰ +entity.10801=⨱ +entity.10803=⨳ +entity.10804=⨴ +entity.10805=⨵ +entity.10806=⨶ +entity.10807=⨷ +entity.10808=⨸ +entity.10809=⨹ +entity.10810=⨺ +entity.10811=⨻ +entity.10812=⨼ +entity.10815=⨿ +entity.10816=⩀ +entity.10818=⩂ +entity.10819=⩃ +entity.10820=⩄ +entity.10821=⩅ +entity.10822=⩆ +entity.10823=⩇ +entity.10824=⩈ +entity.10825=⩉ +entity.10826=⩊ +entity.10827=⩋ +entity.10828=⩌ +entity.10829=⩍ +entity.10832=⩐ +entity.10835=⩓ +entity.10836=⩔ +entity.10837=⩕ +entity.10838=⩖ +entity.10839=⩗ +entity.10840=⩘ +entity.10842=⩚ +entity.10843=⩛ +entity.10844=⩜ +entity.10845=⩝ +entity.10847=⩟ +entity.10854=⩦ +entity.10858=⩪ +entity.10861=⩭ +entity.10863=⩯ +entity.10865=⩱ +entity.10866=⩲ +entity.10867=⩳ +entity.10868=⩴ +entity.10869=⩵ +entity.10871=⩷ +entity.10872=⩸ +entity.10873=⩹ +entity.10874=⩺ +entity.10875=⩻ +entity.10876=⩼ +entity.10877=⩽ +entity.10878=⩾ +entity.10879=⩿ +entity.10880=⪀ +entity.10881=⪁ +entity.10882=⪂ +entity.10883=⪃ +entity.10884=⪄ +entity.10889=⪉ +entity.10890=⪊ +entity.10893=⪍ +entity.10894=⪎ +entity.10895=⪏ +entity.10896=⪐ +entity.10897=⪑ +entity.10898=⪒ +entity.10899=⪓ +entity.10900=⪔ +entity.10903=⪗ +entity.10904=⪘ +entity.10905=⪙ +entity.10906=⪚ +entity.10909=⪝ +entity.10910=⪞ +entity.10911=⪟ +entity.10912=⪠ +entity.10913=⪡ +entity.10914=⪢ +entity.10916=⪤ +entity.10917=⪥ +entity.10918=⪦ +entity.10919=⪧ +entity.10920=⪨ +entity.10921=⪩ +entity.10922=⪪ +entity.10923=⪫ +entity.10924=⪬ +entity.10925=⪭ +entity.10926=⪮ +entity.10927=⪯ +entity.10933=⪵ +entity.10934=⪶ +entity.10939=⪻ +entity.10940=⪼ +entity.10941=⪽ +entity.10942=⪾ +entity.10943=⪿ +entity.10944=⫀ +entity.10945=⫁ +entity.10946=⫂ +entity.10947=⫃ +entity.10948=⫄ +entity.10951=⫇ +entity.10952=⫈ +entity.10959=⫏ +entity.10960=⫐ +entity.10961=⫑ +entity.10962=⫒ +entity.10963=⫓ +entity.10964=⫔ +entity.10965=⫕ +entity.10966=⫖ +entity.10967=⫗ +entity.10968=⫘ +entity.10969=⫙ +entity.10970=⫚ +entity.10971=⫛ +entity.10980=⫤ +entity.10982=⫦ +entity.10983=⫧ +entity.10984=⫨ +entity.10985=⫩ +entity.10987=⫫ +entity.10988=⫬ +entity.10989=⫭ +entity.10990=⫮ +entity.10991=⫯ +entity.10992=⫰ +entity.10993=⫱ +entity.10994=⫲ +entity.10995=⫳ +entity.12298=⟪ +entity.12299=⟫ +entity.12308=❲ +entity.12309=❳ +entity.12312=⦅ +entity.12313=⦆ +entity.12314=⟦ +entity.12315=⟧ +entity.61166==⃥ +entity.61167=⟈ +entity.61168=ȷ +entity.61169=​ +entity.61170=   +entity.61171=​ +entity.61172=​ +entity.61173=​ +entity.61174=ℏ +entity.61175=← +entity.61176=→ +entity.61177=↝̸ +entity.61178=∂̸ +entity.61179=∅ +entity.61180=∉ +entity.61181=∖ +entity.61182=∠⃒ +entity.61183=∣ +entity.61184=∤ +entity.61185=∥ +entity.61186=⫽⃥ +entity.61187=∦ +entity.61188=∩︀ +entity.61189=∪︀ +entity.61190=∼ +entity.61191=∼⃒ +entity.61192=≂̸ +entity.61193=≈ +entity.61194=≍⃒ +entity.61195=≋̸ +entity.61196=≎̸ +entity.61197=≏̸ +entity.61198=≐̸ +entity.61199=≡⃥ +entity.61200=≨︀ +entity.61201=≩︀ +entity.61202=≪⃒ +entity.61203=≪̸ +entity.61204=≫⃒ +entity.61205=≫̸ +entity.61206=≰ +entity.61207=≱ +entity.61208=≿̸ +entity.61209=⟉ +entity.61210=⫋︀ +entity.61211=⫌︀ +entity.61212=⊏̸ +entity.61213=⊐̸ +entity.61214=⊓︀ +entity.61215=⊔︀ +entity.61216=⋘̸ +entity.61217=⋙̸ +entity.61218=⋚︀ +entity.61219=⋛︀ +entity.61220=⊴⃒ +entity.61221=⊵⃒ +entity.61222=⋵̸ +entity.61223=↑ +entity.61224=↓ +entity.61225=⪡̸ +entity.61226=⪢̸ +entity.61227=⤳̸ +entity.61228=⊾ +entity.61229=⧏̸ +entity.61230=⧐̸ +entity.61231=⩭̸ +entity.61232=⩰̸ +entity.61233=⪬︀ +entity.61234=⪭︀ +entity.61235=⪯̸ +entity.61236=⪰̸ +entity.61237=𝒜 +entity.61238=𝒞 +entity.61239=𝒟 +entity.61240=𝒢 +entity.61241=𝒥 +entity.61242=𝒦 +entity.61243=𝒩 +entity.61244=𝒪 +entity.61245=𝒫 +entity.61246=𝒬 +entity.61247=𝒮 +entity.61248=𝒯 +entity.61249=𝒰 +entity.61250=𝒱 +entity.61251=𝒲 +entity.61252=𝒳 +entity.61253=𝒴 +entity.61254=𝒵 +entity.61255=𝒶 +entity.61256=𝒷 +entity.61257=𝒸 +entity.61258=𝒹 +entity.61259=𝒻 +entity.61260=𝒽 +entity.61261=𝒾 +entity.61262=𝒿 +entity.61263=𝓀 +entity.61264=𝓂 +entity.61265=𝓃 +entity.61266=𝓅 +entity.61267=𝓆 +entity.61268=𝓇 +entity.61269=𝓈 +entity.61270=𝓉 +entity.61271=𝓊 +entity.61272=𝓋 +entity.61273=𝓌 +entity.61274=𝓍 +entity.61275=𝓎 +entity.61276=𝓏 +entity.61277=𝔄 +entity.61278=𝔅 +entity.61279=𝔇 +entity.61280=𝔈 +entity.61281=𝔉 +entity.61282=𝔊 +entity.61283=𝔍 +entity.61284=𝔎 +entity.61285=𝔏 +entity.61286=𝔐 +entity.61287=𝔑 +entity.61288=𝔒 +entity.61289=𝔓 +entity.61290=𝔔 +entity.61291=𝔖 +entity.61292=𝔗 +entity.61293=𝔘 +entity.61294=𝔙 +entity.61295=𝔚 +entity.61296=𝔛 +entity.61297=𝔜 +entity.61298=𝔞 +entity.61299=𝔟 +entity.61300=𝔠 +entity.61301=𝔡 +entity.61302=𝔢 +entity.61303=𝔣 +entity.61304=𝔤 +entity.61305=𝔥 +entity.61306=𝔦 +entity.61307=𝔧 +entity.61308=𝔨 +entity.61309=𝔩 +entity.61310=𝔪 +entity.61311=𝔫 +entity.61312=𝔬 +entity.61313=𝔭 +entity.61314=𝔮 +entity.61315=𝔯 +entity.61316=𝔰 +entity.61317=𝔱 +entity.61318=𝔲 +entity.61319=𝔳 +entity.61320=𝔴 +entity.61321=𝔵 +entity.61322=𝔶 +entity.61323=𝔷 +entity.61324=𝔸 +entity.61325=𝔹 +entity.61326=𝔻 +entity.61327=𝔼 +entity.61328=𝔽 +entity.61329=𝔾 +entity.61330=𝕀 +entity.61331=𝕁 +entity.61332=𝕂 +entity.61333=𝕃 +entity.61334=𝕄 +entity.61335=𝕆 +entity.61336=𝕊 +entity.61337=𝕋 +entity.61338=𝕌 +entity.61339=𝕍 +entity.61340=𝕎 +entity.61341=𝕏 +entity.61342=𝕐 +entity.61343=𝕒 +entity.61344=𝕓 +entity.61345=𝕔 +entity.61346=𝕕 +entity.61347=𝕖 +entity.61348=𝕗 +entity.61349=𝕘 +entity.61350=𝕙 +entity.61351=𝕚 +entity.61352=𝕛 +entity.61353=𝕜 +entity.61354=𝕝 +entity.61355=𝕞 +entity.61356=𝕟 +entity.61357=𝕠 +entity.61358=𝕡 +entity.61359=𝕢 +entity.61360=𝕣 +entity.61361=𝕤 +entity.61362=𝕥 +entity.61363=𝕦 +entity.61364=𝕧 +entity.61365=𝕨 +entity.61366=𝕩 +entity.61367=𝕪 +entity.61368=𝕫 +entity.62808=⟬ +entity.62809=⟭ +entity.62838=⟵ +entity.62839=⟶ +entity.62840=⟷ +entity.62841=⟸ +entity.62842=⟹ +entity.62843=⟺ +entity.62845=⟼ +entity.62875=▪ +entity.62876=▫ +entity.62882=⟿ +entity.64256=ff +entity.64257=fi +entity.64258=fl +entity.64259=ffi +entity.64260=ffl +entity.65077=⏜ +entity.65078=⏝ +entity.65079=⏞ +entity.65080=⏟ +entity.65279=⁠ diff --git a/mozilla/xpfe/browser/jar.mn b/mozilla/xpfe/browser/jar.mn index b1a7e821092..c8682f0b3b4 100644 --- a/mozilla/xpfe/browser/jar.mn +++ b/mozilla/xpfe/browser/jar.mn @@ -25,6 +25,9 @@ comm.jar: content/navigator/turboDialog.xul (resources/content/turboDialog.xul) content/navigator/viewsource.js (resources/content/viewsource.js) content/navigator/viewSource.xul (resources/content/viewSource.xul) + content/navigator/viewSourceOverlay.xul (resources/content/viewSourceOverlay.xul) + content/navigator/viewPartialSource.js (resources/content/viewPartialSource.js) + content/navigator/viewPartialSource.xul (resources/content/viewPartialSource.xul) en-US.jar: locale/en-US/navigator/contents.rdf (resources/locale/en-US/contents.rdf) locale/en-US/navigator/viewSource.dtd (resources/locale/en-US/viewSource.dtd) diff --git a/mozilla/xpfe/browser/resources/content/viewPartialSource.js b/mozilla/xpfe/browser/resources/content/viewPartialSource.js new file mode 100644 index 00000000000..ad9b5ae78ed --- /dev/null +++ b/mozilla/xpfe/browser/resources/content/viewPartialSource.js @@ -0,0 +1,478 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org view-source front-end. + * + * The Initial Developer of the Original Code is mozilla.org. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Roger B. Sidje (Original Author) + * Steve Swanson + * Doron Rosenberg + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gDebug = 0; +var gLineCount = 0; +var gStartTargetLine = 0; +var gEndTargetLine = 0; +var gTargetNode = null; + +var gEntityConverter = null; +var gWrapLongLines = false; +const gViewSourceCSS = 'resource:///res/viewsource.css'; +const NS_XHTML = 'http://www.w3.org/1999/xhtml'; + +// These are markers used to delimit the selection during processing. They +// are removed from the final rendering, but we pick space-like characters for +// safety (and futhermore, these are known to be mapped to a 0-length string +// in transliterate.properties). It is okay to set start=end, we use findNext() +// U+200B ZERO WIDTH SPACE +const MARK_SELECTION_START = '\u200B\u200B\u200B\u200B\u200B'; +const MARK_SELECTION_END = '\u200B\u200B\u200B\u200B\u200B'; + +function onLoadViewPartialSource() +{ + // check the view_source.wrap_long_lines pref and set the menuitem's checked attribute accordingly + if (gPrefs) { + try { + var wraplonglinesPrefValue = gPrefs.getBoolPref('view_source.wrap_long_lines'); + if (wraplonglinesPrefValue) { + document.getElementById('menu_wrapLongLines').setAttribute('checked', 'true'); + gWrapLongLines = true; + } + } catch (e) { } + } + + // disable menu items that don't work since the selection is munged and + // the editor doesn't work for MathML + document.getElementById('cmd_savePage').setAttribute('disabled', 'true'); + document.getElementById('cmd_editPage').setAttribute('disabled', 'true'); + + if (window.arguments[3] == 'selection') + viewPartialSourceForSelection(window.arguments[2]); + else + viewPartialSourceForFragment(window.arguments[2], window.arguments[3]); + + window._content.focus(); +} + +//////////////////////////////////////////////////////////////////////////////// +// view-source of a selection with the special effect of remapping the selection +// to the underlying view-source output +function viewPartialSourceForSelection(selection) +{ + var range = selection.getRangeAt(0); + var ancestorContainer = range.commonAncestorContainer; + var doc = ancestorContainer.ownerDocument; + + var startContainer = range.startContainer; + var endContainer = range.endContainer; + var startOffset = range.startOffset; + var endOffset = range.endOffset; + + // let the ancestor be an element + if (ancestorContainer.nodeType == Node.TEXT_NODE || + ancestorContainer.nodeType == Node.CDATA_SECTION_NODE) + ancestorContainer = ancestorContainer.parentNode; + + // each path is a "child sequence" (a.k.a. "tumbler") that + // descends from the ancestor down to the boundary point + var startPath = getPath(ancestorContainer, startContainer); + var endPath = getPath(ancestorContainer, endContainer); + + // clone the fragment of interest and reset everything to be relative to it + ancestorContainer = ancestorContainer.cloneNode(true); + startContainer = ancestorContainer; + endContainer = ancestorContainer; + var i; + for (i = startPath ? startPath.length-1 : -1; i >= 0; i--) { + startContainer = startContainer.childNodes.item(startPath[i]); + } + for (i = endPath ? endPath.length-1 : -1; i >= 0; i--) { + endContainer = endContainer.childNodes.item(endPath[i]); + } + + // add special markers to record the extent of the selection + // note: |startOffset| and |endOffset| are interpreted either as + // offsets in the text data or as child indices (see the Range spec) + // (here, munging the end point first to keep the start point safe...) + var tmpNode; + if (endContainer.nodeType == Node.TEXT_NODE || + endContainer.nodeType == Node.CDATA_SECTION_NODE) { + // do some extra tweaks to try to avoid the view-source output to look like + // ...]... or ...]... (where ']' marks the end of the selection). + // To get a neat output, the idea here is to remap the end point from: + // 1. ...]... to ...]... + // 2. ...]... to ...]... + if ((endOffset > 0 && endOffset < endContainer.data.length-1) || + !endContainer.parentNode || !endContainer.parentNode.parentNode) + endContainer.insertData(endOffset, MARK_SELECTION_END); + else { + tmpNode = doc.createTextNode(MARK_SELECTION_END); + endContainer = endContainer.parentNode; + if (endOffset == 0) + endContainer.parentNode.insertBefore(tmpNode, endContainer); + else + endContainer.parentNode.insertBefore(tmpNode, endContainer.nextSibling); + } + } + else { + tmpNode = doc.createTextNode(MARK_SELECTION_END); + endContainer.insertBefore(tmpNode, endContainer.childNodes.item(endOffset)); + } + + if (startContainer.nodeType == Node.TEXT_NODE || + startContainer.nodeType == Node.CDATA_SECTION_NODE) { + // do some extra tweaks to try to avoid the view-source output to look like + // ...[... or ...[... (where '[' marks the start of the selection). + // To get a neat output, the idea here is to remap the start point from: + // 1. ...[... to ...[... + // 2. ...[... to ...[... + if ((startOffset > 0 && startOffset < startContainer.data.length-1) || + !startContainer.parentNode || !startContainer.parentNode.parentNode) + startContainer.insertData(startOffset, MARK_SELECTION_START); + else { + tmpNode = doc.createTextNode(MARK_SELECTION_START); + startContainer = startContainer.parentNode; + if (startOffset == 0) + startContainer.parentNode.insertBefore(tmpNode, startContainer); + else + startContainer.parentNode.insertBefore(tmpNode, startContainer.nextSibling); + } + } + else { + tmpNode = doc.createTextNode(MARK_SELECTION_START); + startContainer.insertBefore(tmpNode, startContainer.childNodes.item(startOffset)); + } + + // now extract and display the syntax highlighted source + tmpNode = doc.createElementNS(NS_XHTML, 'div'); + tmpNode.appendChild(ancestorContainer); + + // the load is aynchronous and so we will wait until the view-source DOM is done + // before drawing the selection. + window.document.getElementById("appcontent").addEventListener("load", drawSelection, true); + + // all our content is held by the data:URI and URIs are internally stored as utf-8 (see nsIURI.idl) + var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; + getBrowser().webNavigation + .loadURI("view-source:data:text/html;charset=utf-8," + escape(tmpNode.innerHTML), + loadFlags, null, null, null); +} + +//////////////////////////////////////////////////////////////////////////////// +// helper to get a path like FIXptr, but with an array instead of the "tumbler" notation +// see FIXptr: http://lists.w3.org/Archives/Public/www-xml-linking-comments/2001AprJun/att-0074/01-NOTE-FIXptr-20010425.htm +function getPath(ancestor, node) +{ + var n = node; + var p = n.parentNode; + if (n == ancestor || !p) + return null; + var path = new Array(); + if (!path) + return null; + do { + for (var i = 0; i < p.childNodes.length; i++) { + if (p.childNodes.item(i) == n) { + path.push(i); + break; + } + } + n = p; + p = n.parentNode; + } while (n != ancestor && p); + return path; +} + +//////////////////////////////////////////////////////////////////////////////// +// using special markers left in the serialized source, this helper makes the +// underlying markup of the selected fragement to automatically appear as selected +// on the inflated view-source DOM +function drawSelection() +{ + // find the special selection markers that we added earlier, and + // draw the selection between the two... + var findService = null; + try { + // get the find service which stores the global find state + findService = Components.classes["@mozilla.org/find/find_service;1"] + .getService(Components.interfaces.nsIFindService); + } catch(e) { } + if (!findService) + return; + + // cache the current global find state + var matchCase = findService.matchCase; + var entireWord = findService.entireWord; + var wrapFind = findService.wrapFind; + var findBackwards = findService.findBackwards; + var searchString = findService.searchString; + var replaceString = findService.replaceString; + + // setup our find instance + var findInst = getBrowser().webBrowserFind; + findInst.matchCase = true; + findInst.entireWord = false; + findInst.wrapFind = false; + findInst.findBackwards = false; + + // ...lookup the start mark + findInst.searchString = MARK_SELECTION_START; + var startLength = MARK_SELECTION_START.length; + findInst.findNext(); + + var contentWindow = getBrowser().contentDocument.defaultView; + var selection = contentWindow.getSelection(); + var range = selection.getRangeAt(0); + + var startContainer = range.startContainer; + var startOffset = range.startOffset; + + // ...lookup the end mark + findInst.searchString = MARK_SELECTION_END; + var endLength = MARK_SELECTION_END.length; + findInst.findNext(); + + var endContainer = selection.anchorNode; + var endOffset = selection.anchorOffset; + + // reset the selection that find has left + selection.removeAllRanges(); + + // delete the special markers now... + endContainer.deleteData(endOffset, endLength); + startContainer.deleteData(startOffset, startLength); + if (startContainer == endContainer) + endOffset -= startLength; // has shrunk if on same text node... + range.setEnd(endContainer, endOffset); + + // show the selection and scroll it into view + selection.addRange(range); + // the default behavior of the selection is to scroll at the end of + // the selection, whereas in this situation, it is more user-friendly + // to scroll at the beginning. So we override the default behavior here + try { + getBrowser().docShell + .QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsISelectionDisplay) + .QueryInterface(Components.interfaces.nsISelectionController) + .scrollSelectionIntoView(Components.interfaces.nsISelectionController.SELECTION_NORMAL, + Components.interfaces.nsISelectionController.SELECTION_ANCHOR_REGION); + } + catch(e) { } + + // restore the current find state + findService.matchCase = matchCase; + findService.entireWord = entireWord; + findService.wrapFind = wrapFind; + findService.findBackwards = findBackwards; + findService.searchString = searchString; + findService.replaceString = replaceString; + + findInst.matchCase = matchCase; + findInst.entireWord = entireWord; + findInst.wrapFind = wrapFind; + findInst.findBackwards = findBackwards; + findInst.searchString = searchString; +} + +//////////////////////////////////////////////////////////////////////////////// +// special handler for markups such as MathML where reformatting the output is +// helpful +function viewPartialSourceForFragment(node, context) +{ + gTargetNode = node; + if (gTargetNode && gTargetNode.nodeType == Node.TEXT_NODE) + gTargetNode = gTargetNode.parentNode; + + // walk up the tree to the top-level element (e.g., , ) + var topTag; + if (context == 'mathml') + topTag = 'math'; + else + throw 'not reached'; + var topNode = gTargetNode; + while (topNode && topNode.localName != topTag) + topNode = topNode.parentNode; + if (!topNode) + return; + + // serialize (note: the main window overrides the title set here) + var wrapClass = gWrapLongLines ? ' class="wrap"' : ''; + var source = + '' + + 'Mozilla' + + '' + + '' + + '' + + '' + + '
'
+  + getOuterMarkup(topNode, 0)
+  + '
' + ; // end + + // display + var doc = getBrowser().contentDocument; + doc.open("text/html", "replace"); + doc.write(source); + doc.close(); +} + +//////////////////////////////////////////////////////////////////////////////// +function getInnerMarkup(node, indent) { + var str = ''; + for (var i = 0; i < node.childNodes.length; i++) { + str += getOuterMarkup(node.childNodes.item(i), indent); + } + return str; +} + +//////////////////////////////////////////////////////////////////////////////// +function getOuterMarkup(node, indent) { + var newline = ''; + var padding = ''; + var str = ''; + if (node == gTargetNode) { + gStartTargetLine = gLineCount; + str += '
';
+  }
+
+  switch (node.nodeType) {
+  case Node.ELEMENT_NODE: // Element
+    // to avoid the wide gap problem, '\n' is not emitted on the first
+    // line and the lines before & after the 
...
+ if (gLineCount > 0 && + gLineCount != gStartTargetLine && + gLineCount != gEndTargetLine) { + newline = '\n'; + } + gLineCount++; + if (gDebug) { + newline += gLineCount; + } + for (var k = 0; k < indent; k++) { + padding += ' '; + } + str += newline + padding + + '<' + node.nodeName + ''; + for (var i = 0; i < node.attributes.length; i++) { + var attr = node.attributes.item(i); + if (!gDebug && attr.nodeName.match(/^[-_]moz/)) { + continue; + } + str += ' ' + + attr.nodeName + + '="' + + unicodeTOentity(attr.nodeValue) + + '"'; + } + if (!node.hasChildNodes()) { + str += '/>'; + } + else { + str += '>'; + var oldLine = gLineCount; + str += getInnerMarkup(node, indent + 2); + if (oldLine == gLineCount) { + newline = ''; + padding = ''; + } + else { + newline = (gLineCount == gEndTargetLine) ? '' : '\n'; + gLineCount++; + if (gDebug) { + newline += gLineCount; + } + } + str += newline + padding + + '</' + node.nodeName + '>'; + } + break; + case Node.TEXT_NODE: // Text + var tmp = node.nodeValue; + tmp = tmp.replace(/(\n|\r|\t)+/g, " "); + tmp = tmp.replace(/^ +/, ""); + tmp = tmp.replace(/ +$/, ""); + if (tmp.length != 0) { + str += '' + unicodeTOentity(tmp) + ''; + } + break; + default: + break; + } + + if (node == gTargetNode) { + gEndTargetLine = gLineCount; + str += '
';
+  }
+  return str;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+function unicodeTOentity(text)
+{
+  if (!gEntityConverter) {
+    try {
+      gEntityConverter = Components.classes["@mozilla.org/intl/entityconverter;1"]
+                                   .createInstance(Components.interfaces.nsIEntityConverter);
+    } catch(e) { }
+  }
+  var entityVersion = Components.interfaces.nsIEntityConverter.html40
+                    + Components.interfaces.nsIEntityConverter.mathml20;
+
+  var str = '';
+  for (var i = 0; i < text.length; i++) {
+    var c = text.charCodeAt(i);
+    if ((c <= 0x7F) || !gEntityConverter) {
+      if (text[i] == '<')
+        str += '&lt;';
+      else if (text[i] == '>')
+        str += '&gt;';
+      else if (text[i] == '&')
+        str += '&amp;';
+      else
+        str += text[i];
+    }
+    else {
+      try {
+        var unichar = gEntityConverter.ConvertToEntity(text[i], entityVersion);
+        str += '&'
+            +  unichar.substring(1, unichar.length) // extract '&'
+            +  '';
+      }
+      catch(e) {
+        str += text[i];
+      }
+    }
+  }
+  return str;
+}
diff --git a/mozilla/xpfe/browser/resources/content/viewPartialSource.xul b/mozilla/xpfe/browser/resources/content/viewPartialSource.xul
new file mode 100644
index 00000000000..577e3f3a43a
--- /dev/null
+++ b/mozilla/xpfe/browser/resources/content/viewPartialSource.xul
@@ -0,0 +1,82 @@
+  
+ 
+
+
+
+
+
+
+%brandDTD;
+
+%sourceDTD;
+
+%navigatorDTD;
+
+%contentAreaCommandsDTD;
+]>
+
+
+
+