nokogiri 1.5.0.beta.3 → 1.5.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

Files changed (87) hide show
  1. data/CHANGELOG.ja.rdoc +32 -16
  2. data/CHANGELOG.rdoc +18 -0
  3. data/Manifest.txt +1 -2
  4. data/README.rdoc +27 -3
  5. data/Rakefile +39 -83
  6. data/ext/java/nokogiri/EncodingHandler.java +1 -1
  7. data/ext/java/nokogiri/HtmlDocument.java +11 -14
  8. data/ext/java/nokogiri/HtmlElementDescription.java +1 -1
  9. data/ext/java/nokogiri/HtmlEntityLookup.java +1 -1
  10. data/ext/java/nokogiri/HtmlSaxParserContext.java +13 -10
  11. data/ext/java/nokogiri/NokogiriService.java +103 -34
  12. data/ext/java/nokogiri/XmlAttr.java +14 -6
  13. data/ext/java/nokogiri/XmlAttributeDecl.java +1 -1
  14. data/ext/java/nokogiri/XmlCdata.java +3 -1
  15. data/ext/java/nokogiri/XmlComment.java +3 -1
  16. data/ext/java/nokogiri/XmlDocument.java +29 -8
  17. data/ext/java/nokogiri/XmlDocumentFragment.java +14 -13
  18. data/ext/java/nokogiri/XmlDtd.java +5 -2
  19. data/ext/java/nokogiri/XmlElement.java +2 -1
  20. data/ext/java/nokogiri/XmlElementContent.java +1 -1
  21. data/ext/java/nokogiri/XmlElementDecl.java +2 -1
  22. data/ext/java/nokogiri/XmlEntityDecl.java +2 -1
  23. data/ext/java/nokogiri/XmlEntityReference.java +1 -1
  24. data/ext/java/nokogiri/XmlNamespace.java +3 -2
  25. data/ext/java/nokogiri/XmlNode.java +17 -10
  26. data/ext/java/nokogiri/XmlNodeSet.java +40 -13
  27. data/ext/java/nokogiri/XmlProcessingInstruction.java +1 -1
  28. data/ext/java/nokogiri/XmlReader.java +3 -1
  29. data/ext/java/nokogiri/XmlRelaxng.java +37 -92
  30. data/ext/java/nokogiri/XmlSaxParserContext.java +25 -11
  31. data/ext/java/nokogiri/XmlSaxPushParser.java +6 -4
  32. data/ext/java/nokogiri/XmlSchema.java +190 -46
  33. data/ext/java/nokogiri/XmlSyntaxError.java +42 -37
  34. data/ext/java/nokogiri/XmlText.java +3 -2
  35. data/ext/java/nokogiri/XmlXpathContext.java +8 -4
  36. data/ext/java/nokogiri/XsltStylesheet.java +12 -10
  37. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +8 -7
  38. data/ext/java/nokogiri/internals/NokogiriDocumentCache.java +1 -1
  39. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +11 -5
  40. data/ext/java/nokogiri/internals/NokogiriHandler.java +36 -9
  41. data/ext/java/nokogiri/internals/NokogiriHelpers.java +21 -22
  42. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +5 -4
  43. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +1 -1
  44. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +2 -1
  45. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +1 -1
  46. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +2 -1
  47. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +15 -9
  48. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +1 -1
  49. data/ext/java/nokogiri/internals/ParserContext.java +18 -7
  50. data/ext/java/nokogiri/internals/PushInputStream.java +1 -1
  51. data/ext/java/nokogiri/internals/ReaderNode.java +7 -6
  52. data/ext/java/nokogiri/internals/SaveContext.java +16 -10
  53. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +13 -5
  54. data/ext/java/nokogiri/internals/XmlDeclHandler.java +1 -1
  55. data/ext/java/nokogiri/internals/XmlDomParser.java +1 -1
  56. data/ext/java/nokogiri/internals/XmlDomParserContext.java +13 -8
  57. data/ext/java/nokogiri/internals/XmlSaxParser.java +1 -1
  58. data/ext/java/nokogiri/internals/XsltExtensionFunction.java +1 -1
  59. data/ext/nokogiri/extconf.rb +3 -3
  60. data/ext/nokogiri/xml_document.c +9 -0
  61. data/ext/nokogiri/xml_sax_parser.c +4 -2
  62. data/lib/nokogiri.rb +9 -6
  63. data/lib/nokogiri/css.rb +1 -3
  64. data/lib/nokogiri/css/parser.rb +665 -70
  65. data/lib/nokogiri/css/parser.y +3 -1
  66. data/lib/nokogiri/css/parser_extras.rb +91 -0
  67. data/lib/nokogiri/css/tokenizer.rb +148 -3
  68. data/lib/nokogiri/css/tokenizer.rex +1 -1
  69. data/lib/nokogiri/html/document.rb +138 -11
  70. data/lib/nokogiri/html/sax/parser.rb +6 -2
  71. data/lib/nokogiri/version.rb +1 -1
  72. data/lib/nokogiri/xml/node.rb +2 -2
  73. data/lib/nokogiri/xml/node/save_options.rb +3 -0
  74. data/lib/nokogiri/xml/node_set.rb +1 -1
  75. data/test/css/test_tokenizer.rb +8 -0
  76. data/test/helper.rb +2 -0
  77. data/test/html/sax/test_parser.rb +43 -0
  78. data/test/html/test_document.rb +59 -0
  79. data/test/html/test_document_encoding.rb +48 -0
  80. data/test/html/test_element_description.rb +1 -1
  81. data/test/xml/sax/test_parser.rb +16 -0
  82. data/test/xml/test_document.rb +3 -1
  83. data/test/xml/test_node.rb +4 -1
  84. data/test/xml/test_node_set.rb +10 -0
  85. metadata +90 -107
  86. data/lib/nokogiri/css/generated_parser.rb +0 -676
  87. data/lib/nokogiri/css/generated_tokenizer.rb +0 -145
@@ -1,31 +1,47 @@
1
- == 1.5.0 beta3 / 2010/12/02
1
+ == 1.5.0 beta3 2010年12月2日
2
2
 
3
- * Notes
3
+ *
4
4
 
5
- * JRuby performance tuning
6
- * See changelog from 1.4.4
5
+ * JRubyでの性能改善
6
+ * 1.4.4からの変更点を参照
7
7
 
8
- * Bugfixes
8
+ * バグの修正
9
+
10
+ * Node#inner_textはnilを返さなくなった. (JRuby) #264
11
+
12
+ == 1.5.0 beta2 2010年7月30日
13
+
14
+ * 註
9
15
 
10
- * Node#inner_text no longer returns nil. (JRuby) #264
16
+ * 1.4.3からの変更点を参照
11
17
 
12
- == 1.5.0 beta2 / 2010/07/30
18
+ == 1.5.0 beta1 2010年5月22日
13
19
 
14
- * Notes
20
+ *
15
21
 
16
- * See changelog from 1.4.3
22
+ * 新しいピュアJavaバックエンドによりJRubyサポートを追加
17
23
 
18
- == 1.5.0 beta1 / 2010/05/22
24
+ * 廃止
19
25
 
20
- * Notes
26
+ * Ruby 1.8.6は非推奨となった. インストールできるかもしれないが、正式なサポートは終了.
27
+ * LibXML 2.6.16および古いバージョンは非推奨. インストールできない.
28
+ * FFIサポートは削除された.
21
29
 
22
- * JRuby support is provided by a new pure-java backend.
30
+ === 1.4.5 / 未リリース
23
31
 
24
- * Deprecations
32
+ * 新機能
33
+
34
+ * Nokogiri::HTML::Document#title アクセサメソッドでHTML文書のタイトルを読み書きできる
35
+
36
+ * バグの修正
25
37
 
26
- * Ruby 1.8.6 is deprecated. Nokogiri will install, but official support is ended.
27
- * LibXML 2.6.16 and earlier are deprecated. Nokogiri will refuse to install.
28
- * FFI support is removed.
38
+ * Node#serialize とその仲間達はSaveOptionオブジェクトを受け入れる
39
+ * Nokogiri::CSS::Parser has-a Nokogiri::CSS::Tokenizer
40
+ * [JRUBY+FFIのみ] 「弱い参照」はスレッドセーフになった. #355
41
+ * HTML::SAX::Parserから呼ばれるstart_element()コールバックのattributes引数はHTML::XML::Parserによるエミュレートコールバックと同じく連想配列になった. rel. #356
42
+ * HTML::SAX::Parserのparse*()メソッドはXML::SAX::Parser同様に渡されたブロックをコールバックするようになった.
43
+ * HTMLパーサーのエンコーディング判定をlibxml2の仕様を超えて拡張・改善した. (XML宣言のencodingを認識、非ASCII文字出現後のmetaタグも文字化けを生じずに反映)
44
+ * Document#remove_namespaces! は名前空間付きの属性に対応した. #396
29
45
 
30
46
  === 1.4.4 2010年11月15日
31
47
 
@@ -27,6 +27,24 @@
27
27
  * LibXML 2.6.16 and earlier are deprecated. Nokogiri will refuse to install.
28
28
  * FFI support is removed.
29
29
 
30
+ === 1.4.5 / unrelease
31
+
32
+ * New Features
33
+
34
+ * Nokogiri::HTML::Document#title accessor gets and sets the document title.
35
+
36
+ * Bugfixes
37
+
38
+ * Node#serialize-and-friends now accepts a SaveOption object as the, erm, save object.
39
+ * Nokogiri::CSS::Parser has-a Nokogiri::CSS::Tokenizer
40
+ * [JRUBY+FFI only] Weak references are now threadsafe. #355
41
+ * Make direct start_element() callback (currently used for
42
+ HTML::SAX::Parser) pass attributes in assoc array, just as
43
+ emulated start_element() callback does. rel. #356
44
+ * HTML::SAX::Parser should call back a block given to parse*() if any, just as XML::SAX::Parser does.
45
+ * Add further encoding detection to HTML parser that libxml2 does not do.
46
+ * Document#remove_namespaces! now handles attributes with namespaces. #396
47
+
30
48
  === 1.4.4 / 2010-11-15
31
49
 
32
50
  * New Features
@@ -134,11 +134,10 @@ lib/nekodtd.jar
134
134
  lib/nekohtml.jar
135
135
  lib/nokogiri.rb
136
136
  lib/nokogiri/css.rb
137
- lib/nokogiri/css/generated_parser.rb
138
- lib/nokogiri/css/generated_tokenizer.rb
139
137
  lib/nokogiri/css/node.rb
140
138
  lib/nokogiri/css/parser.rb
141
139
  lib/nokogiri/css/parser.y
140
+ lib/nokogiri/css/parser_extras.rb
142
141
  lib/nokogiri/css/syntax_error.rb
143
142
  lib/nokogiri/css/tokenizer.rb
144
143
  lib/nokogiri/css/tokenizer.rex
@@ -112,10 +112,34 @@ Binary packages are available for:
112
112
 
113
113
  == DEVELOPMENT:
114
114
 
115
- Developing Nokogiri requires racc and rexical.
115
+ === Developing on C Ruby (MRI)
116
116
 
117
- * rake install:deps
118
- * rake test
117
+ Developing Nokogiri requires racc and rexical to generate the parser and
118
+ tokenizer. To start development, make sure you have `libxml2` and `libxslt`
119
+ installed.
120
+
121
+ Then install hoe and rake-compiler:
122
+
123
+ $ gem install hoe rake-compiler
124
+
125
+ Then run rake:
126
+
127
+ $ rake
128
+
129
+ === Developing on JRuby
130
+
131
+ Currently, development with JRuby depends on C Ruby being installed. With
132
+ normal C Ruby, install racc and rexical:
133
+
134
+ $ gem install racc rexical
135
+
136
+ Make sure hoe and rake compiler are installed with JRuby:
137
+
138
+ $ jgem install hoe rake-compiler
139
+
140
+ Then run rake:
141
+
142
+ $ jruby -S rake
119
143
 
120
144
  == LICENSE:
121
145
 
data/Rakefile CHANGED
@@ -7,18 +7,20 @@ require 'hoe'
7
7
  windows = RUBY_PLATFORM =~ /(mswin|mingw)/i
8
8
  java = RUBY_PLATFORM =~ /java/
9
9
 
10
- GENERATED_PARSER = "lib/nokogiri/css/generated_parser.rb"
11
- GENERATED_TOKENIZER = "lib/nokogiri/css/generated_tokenizer.rb"
10
+ GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
11
+ GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
12
12
  CROSS_DIR = File.join(File.dirname(__FILE__), 'tmp', 'cross')
13
13
 
14
14
  EXTERNAL_JAVA_LIBRARIES = %w{isorelax jing nekohtml nekodtd xercesImpl}.map{|x| "lib/#{x}.jar"}
15
- JAVA_EXT = "lib/nokogiri/nokogiri.jar"
16
15
  JRUBY_HOME = Config::CONFIG['prefix']
16
+ LIB_DIR = File.expand_path('lib')
17
+ CLASSPATH = "#{JRUBY_HOME}/lib/jruby.jar:#{LIB_DIR}/nekohtml.jar:#{LIB_DIR}/nekodtd.jar:#{LIB_DIR}/xercesImpl.jar:#{LIB_DIR}/isorelax.jar:#{LIB_DIR}/jing.jar"
17
18
 
18
19
  # Make sure hoe-debugging is installed
19
20
  Hoe.plugin :debugging
20
21
  Hoe.plugin :git
21
22
 
23
+
22
24
  HOE = Hoe.spec 'nokogiri' do
23
25
  developer('Aaron Patterson', 'aaronp@rubyforge.org')
24
26
  developer('Mike Dalessio', 'mike.dalessio@gmail.com')
@@ -35,14 +37,19 @@ HOE = Hoe.spec 'nokogiri' do
35
37
  ]
36
38
 
37
39
  %w{ racc rexical rake-compiler }.each do |dep|
38
- self.extra_dev_deps << [dep, '>= 0']
40
+ extra_dev_deps << [dep, '>= 0']
39
41
  end
40
- self.extra_dev_deps << ["minitest", ">= 1.6.0"]
42
+ extra_dev_deps << ["minitest", ">= 1.6.0"]
41
43
 
42
- self.spec_extras = { :extensions => ["ext/nokogiri/extconf.rb"] }
44
+ if java
45
+ self.spec_extras = { :platform => 'java' }
46
+ else
47
+ self.spec_extras = { :extensions => ["ext/nokogiri/extconf.rb"] }
48
+ end
43
49
 
44
50
  self.testlib = :minitest
45
51
  end
52
+
46
53
  Hoe.add_include_dirs '.'
47
54
 
48
55
  task :ws_docs do
@@ -61,11 +68,22 @@ task :ws_docs do
61
68
  RDoc::RDoc.new.document options
62
69
  end
63
70
 
64
- unless java
65
- gem 'rake-compiler', '>= 0.4.1'
66
- require "rake/extensiontask"
67
71
 
68
- RET = Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
72
+ gem 'rake-compiler', '>= 0.4.1'
73
+ if java
74
+ require "rake/javaextensiontask"
75
+ Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
76
+ ext.ext_dir = 'ext/java'
77
+ ext.classpath = CLASSPATH
78
+ end
79
+ path = "pkg/#{HOE.spec.name}-#{HOE.spec.version}"
80
+ task path => :compile do
81
+ cp 'lib/nokogiri/nokogiri.jar', File.join(path, 'lib')
82
+ HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
83
+ end
84
+ else
85
+ require "rake/extensiontask"
86
+ Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
69
87
  ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
70
88
 
71
89
  ext.config_options << ENV['EXTOPTS']
@@ -73,9 +91,9 @@ unless java
73
91
  ext.cross_platform = 'i386-mingw32'
74
92
  # ext.cross_platform = 'i386-mswin32'
75
93
  ext.cross_config_options <<
76
- "--with-xml2-include=#{File.join(CROSS_DIR, 'include', 'libxml2')}"
94
+ "--with-xml2-include=#{File.join(CROSS_DIR, 'include', 'libxml2')}"
77
95
  ext.cross_config_options <<
78
- "--with-xml2-lib=#{File.join(CROSS_DIR, 'lib')}"
96
+ "--with-xml2-lib=#{File.join(CROSS_DIR, 'lib')}"
79
97
  ext.cross_config_options << "--with-iconv-dir=#{CROSS_DIR}"
80
98
  ext.cross_config_options << "--with-xslt-dir=#{CROSS_DIR}"
81
99
  ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
@@ -83,49 +101,11 @@ unless java
83
101
  end
84
102
 
85
103
  namespace :java do
86
- desc "Removes all generated during compilation .class files."
87
- task :clean_classes do
88
- (FileList['ext/java/nokogiri/internals/*.class'] + FileList['ext/java/nokogiri/*.class'] + FileList['ext/java/*.class']).to_a.each do |file|
89
- File.delete file
90
- end
91
- end
92
-
93
- desc "Removes the generated .jar"
94
- task :clean_jar do
95
- FileList['lib/nokogiri/*.jar'].each{|f| File.delete f }
96
- end
97
-
98
- desc "Same as java:clean_classes and java:clean_jar"
99
- task :clean_all => ["java:clean_classes", "java:clean_jar"]
100
-
101
- desc "Build a gem targetted for JRuby"
102
- task :gem => ['java:spec', GENERATED_PARSER, GENERATED_TOKENIZER, :build] do
103
- raise "ERROR: please run this task under jruby" unless java
104
- system "gem build nokogiri.gemspec"
105
- FileUtils.mkdir_p "pkg"
106
- FileUtils.mv Dir.glob("nokogiri*-java.gem"), "pkg"
107
- end
108
-
109
104
  task :spec do
110
105
  File.open("#{HOE.name}.gemspec", 'w') do |f|
111
- HOE.spec.platform = 'java'
112
- HOE.spec.files += [GENERATED_PARSER, GENERATED_TOKENIZER, JAVA_EXT] + EXTERNAL_JAVA_LIBRARIES
113
- HOE.spec.extensions = []
114
106
  f.write(HOE.spec.to_ruby)
115
107
  end
116
108
  end
117
-
118
- desc "Build external library"
119
- task :build_external do
120
- Dir.chdir('ext/java') do
121
- LIB_DIR = '../../lib'
122
- CLASSPATH = "#{JRUBY_HOME}/lib/jruby.jar:#{LIB_DIR}/nekohtml.jar:#{LIB_DIR}/nekodtd.jar:#{LIB_DIR}/xercesImpl.jar:#{LIB_DIR}/isorelax.jar:#{LIB_DIR}/jing.jar"
123
- sh "javac -g -cp #{CLASSPATH} nokogiri/*.java nokogiri/internals/*.java"
124
- sh "jar cf ../../#{JAVA_EXT} nokogiri/*.class nokogiri/internals/*.class"
125
- end
126
- end
127
-
128
- task :build => ["java:clean_jar", "java:build_external", "java:clean_classes"]
129
109
  end
130
110
 
131
111
  namespace :gem do
@@ -142,21 +122,13 @@ namespace :gem do
142
122
  end
143
123
 
144
124
  file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
145
- begin
146
- racc = Config::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
147
- racc = "#{::Config::CONFIG['bindir']}/racc" if racc.empty?
148
- sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
149
- rescue
150
- abort "need racc, sudo gem install racc"
151
- end
125
+ racc = Config::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
126
+ racc = "#{::Config::CONFIG['bindir']}/racc" if racc.empty?
127
+ sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
152
128
  end
153
129
 
154
130
  file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
155
- begin
156
- sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
157
- rescue
158
- abort "need rexical, sudo gem install rexical"
159
- end
131
+ sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
160
132
  end
161
133
 
162
134
  require 'tasks/test'
@@ -176,38 +148,22 @@ end
176
148
  # required_ruby_version
177
149
 
178
150
  # Only do this on unix, since we can't build on windows
179
- unless windows || java
151
+ unless windows
180
152
  [:compile, :check_manifest].each do |task_name|
181
153
  Rake::Task[task_name].prerequisites << GENERATED_PARSER
182
154
  Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
155
+ if java
156
+ Rake::Task[task_name].prerequisites.concat EXTERNAL_JAVA_LIBRARIES
157
+ end
183
158
  end
184
159
 
185
160
  Rake::Task[:test].prerequisites << :compile
161
+ Rake::Task[:test].prerequisites << :check_extra_deps unless java
186
162
  if Hoe.plugins.include?(:debugging)
187
163
  ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
188
164
  Rake::Task["test:#{task_name}"].prerequisites << :compile
189
165
  end
190
166
  end
191
- else
192
- [:test, :check_manifest].each do |task_name|
193
- if Rake::Task[task_name]
194
- Rake::Task[task_name].prerequisites << GENERATED_PARSER
195
- Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
196
- end
197
- end
198
- end
199
-
200
- namespace :install do
201
- desc "Install rex and racc for development"
202
- task :deps => %w(rexical racc)
203
-
204
- task :racc do |t|
205
- sh "sudo gem install racc"
206
- end
207
-
208
- task :rexical do
209
- sh "sudo gem install rexical"
210
- end
211
167
  end
212
168
 
213
169
  namespace :rip do
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2010:
4
+ * Copyright (c) 2008 - 2011:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2010:
4
+ * Copyright (c) 2008 - 2011:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -32,6 +32,7 @@
32
32
 
33
33
  package nokogiri;
34
34
 
35
+ import static nokogiri.internals.NokogiriHelpers.getNokogiriClass;
35
36
  import nokogiri.internals.HtmlDomParserContext;
36
37
  import nokogiri.internals.SaveContext;
37
38
 
@@ -49,6 +50,8 @@ import org.w3c.dom.DocumentType;
49
50
  /**
50
51
  * Class for Nokogiri::HTML::Document.
51
52
  *
53
+ * @author sergio
54
+ * @author Yoko Harada <yokolet@gmail.com>
52
55
  */
53
56
  @JRubyClass(name="Nokogiri::HTML::Document", parent="Nokogiri::XML::Document")
54
57
  public class HtmlDocument extends XmlDocument {
@@ -62,20 +65,20 @@ public class HtmlDocument extends XmlDocument {
62
65
  }
63
66
 
64
67
  @JRubyMethod(name="new", meta = true, rest = true, required=0)
65
- public static IRubyObject rbNew(ThreadContext context, IRubyObject cls,
68
+ public static IRubyObject rbNew(ThreadContext context, IRubyObject klazz,
66
69
  IRubyObject[] args) {
67
- HtmlDocument doc = null;
70
+ HtmlDocument htmlDocument = null;
68
71
  try {
69
72
  Document docNode = createNewDocument();
70
- doc = new HtmlDocument(context.getRuntime(), (RubyClass) cls, docNode);
73
+ htmlDocument = (HtmlDocument) NokogiriService.HTML_DOCUMENT_ALLOCATOR.allocate(context.getRuntime(), (RubyClass) klazz);
74
+ htmlDocument.setNode(context, docNode);
71
75
  } catch (Exception ex) {
72
- throw context.getRuntime()
73
- .newRuntimeError("couldn't create document: "+ex.toString());
76
+ throw context.getRuntime().newRuntimeError("couldn't create document: "+ex.toString());
74
77
  }
75
78
 
76
- RuntimeHelpers.invoke(context, doc, "initialize", args);
79
+ RuntimeHelpers.invoke(context, htmlDocument, "initialize", args);
77
80
 
78
- return doc;
81
+ return htmlDocument;
79
82
  }
80
83
 
81
84
  public static IRubyObject do_parse(ThreadContext context,
@@ -117,12 +120,6 @@ public class HtmlDocument extends XmlDocument {
117
120
  return do_parse(context, cls, args);
118
121
  }
119
122
 
120
-
121
- @JRubyMethod
122
- public static IRubyObject serialize(ThreadContext context, IRubyObject htmlDoc) {
123
- throw context.getRuntime().newNotImplementedError("not implemented");
124
- }
125
-
126
123
  @Override
127
124
  public void saveContent(ThreadContext context, SaveContext ctx) {
128
125
  Document doc = getDocument();
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2010:
4
+ * Copyright (c) 2008 - 2011:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2010:
4
+ * Copyright (c) 2008 - 2011:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2010:
4
+ * Copyright (c) 2008 - 2011:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -59,6 +59,9 @@ import org.xml.sax.SAXException;
59
59
  /**
60
60
  * Class for Nokogiri::HTML::SAX::ParserContext.
61
61
  *
62
+ * @author serabe
63
+ * @author Patrick Mahoney <pat@polycrystal.org>
64
+ * @author Yoko Harada <yokolet@gmail.com>
62
65
  */
63
66
 
64
67
  @JRubyClass(name="Nokogiri::HTML::SAX::ParserContext", parent="Nokogiri::XML::SAX::ParserContext")
@@ -67,7 +70,7 @@ public class HtmlSaxParserContext extends XmlSaxParserContext {
67
70
  public HtmlSaxParserContext(Ruby ruby, RubyClass rubyClass) {
68
71
  super(ruby, rubyClass);
69
72
  }
70
-
73
+
71
74
  @Override
72
75
  protected AbstractSAXParser createParser() throws SAXException {
73
76
  SAXParser parser = new SAXParser();
@@ -89,8 +92,8 @@ public class HtmlSaxParserContext extends XmlSaxParserContext {
89
92
  IRubyObject klazz,
90
93
  IRubyObject data,
91
94
  IRubyObject encoding) {
92
- HtmlSaxParserContext ctx =
93
- new HtmlSaxParserContext(context.getRuntime(), (RubyClass) klazz);
95
+ HtmlSaxParserContext ctx = (HtmlSaxParserContext) NokogiriService.HTML_SAXPARSER_CONTEXT_ALLOCATOR.allocate(context.getRuntime(), (RubyClass)klazz);
96
+ ctx.initialize(context.getRuntime());
94
97
  String javaEncoding = findEncoding(context, encoding);
95
98
  if (javaEncoding != null) {
96
99
  String input = applyEncoding(rubyStringToString(data), javaEncoding);
@@ -195,8 +198,8 @@ public class HtmlSaxParserContext extends XmlSaxParserContext {
195
198
  IRubyObject klazz,
196
199
  IRubyObject data,
197
200
  IRubyObject encoding) {
198
- HtmlSaxParserContext ctx =
199
- new HtmlSaxParserContext(context.getRuntime(), (RubyClass) klazz);
201
+ HtmlSaxParserContext ctx = (HtmlSaxParserContext) NokogiriService.HTML_SAXPARSER_CONTEXT_ALLOCATOR.allocate(context.getRuntime(), (RubyClass)klazz);
202
+ ctx.initialize(context.getRuntime());
200
203
  ctx.setInputSourceFile(context, data);
201
204
  String javaEncoding = findEncoding(context, encoding);
202
205
  if (javaEncoding != null) {
@@ -210,8 +213,8 @@ public class HtmlSaxParserContext extends XmlSaxParserContext {
210
213
  IRubyObject klazz,
211
214
  IRubyObject data,
212
215
  IRubyObject encoding) {
213
- HtmlSaxParserContext ctx =
214
- new HtmlSaxParserContext(context.getRuntime(), (RubyClass) klazz);
216
+ HtmlSaxParserContext ctx = (HtmlSaxParserContext) NokogiriService.HTML_SAXPARSER_CONTEXT_ALLOCATOR.allocate(context.getRuntime(), (RubyClass)klazz);
217
+ ctx.initialize(context.getRuntime());
215
218
  ctx.setInputSource(context, data);
216
219
  String javaEncoding = findEncoding(context, encoding);
217
220
  if (javaEncoding != null) {
@@ -228,8 +231,8 @@ public class HtmlSaxParserContext extends XmlSaxParserContext {
228
231
  public static IRubyObject parse_stream(ThreadContext context,
229
232
  IRubyObject klazz,
230
233
  InputStream stream) {
231
- HtmlSaxParserContext ctx =
232
- new HtmlSaxParserContext(context.getRuntime(), (RubyClass)klazz);
234
+ HtmlSaxParserContext ctx = (HtmlSaxParserContext) NokogiriService.HTML_SAXPARSER_CONTEXT_ALLOCATOR.allocate(context.getRuntime(), (RubyClass)klazz);
235
+ ctx.initialize(context.getRuntime());
233
236
  ctx.setInputSource(stream);
234
237
  return ctx;
235
238
  }