Changeset 9639 in webkit
- Timestamp:
- Jul 9, 2005, 1:19:28 PM (20 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 deleted
- 139 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/fast/dom/css-dom-read-expected.txt
r9435 r9639 10 10 .three { display: list-item; list-style-type: square; margin-left: 3em; } 11 11 .four { display: none; color: red; } 12 I{ display: block; }12 i { display: block; } 13 13 -
trunk/LayoutTests/fast/overflow/003-expected.txt
r8582 r9639 5 5 layer at (10,10) size 282x302 clip at (11,11) size 265x300 scrollHeight 1292 6 6 RenderBlock {channel} at (0,0) size 282x302 [bgcolor=#EEEEEE] [border: (1px solid #000000)] 7 RenderBlock { TITLE} at (11,11) size 255x197 RenderBlock {title} at (11,11) size 255x19 8 8 RenderText {TEXT} at (0,0) size 154x19 9 9 text run at (0,0) width 154: "scottandrew.com" … … 12 12 text run at (0,0) width 191: "DHTML, DOM and JavaScript News" 13 13 RenderBlock {item} at (1,62) size 265x97 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 14 RenderInline { TITLE} at (0,0) size 233x1514 RenderInline {title} at (0,0) size 233x15 15 15 RenderText {TEXT} at (10,11) size 233x15 16 16 text run at (10,11) width 233: "DHTML Animation Array Generator" … … 25 25 RenderText {TEXT} at (0,0) size 0x0 26 26 RenderBlock {item} at (1,169) size 265x82 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 27 RenderInline { TITLE} at (0,0) size 177x1527 RenderInline {title} at (0,0) size 177x15 28 28 RenderText {TEXT} at (10,11) size 177x15 29 29 text run at (10,11) width 177: "DOM and Extended Entries" … … 39 39 RenderText {TEXT} at (0,0) size 0x0 40 40 RenderBlock {item} at (1,261) size 265x82 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 41 RenderInline { TITLE} at (0,0) size 164x1541 RenderInline {title} at (0,0) size 164x15 42 42 RenderText {TEXT} at (10,11) size 164x15 43 43 text run at (10,11) width 164: "cellspacing and the DOM" … … 53 53 RenderText {TEXT} at (0,0) size 0x0 54 54 RenderBlock {item} at (1,353) size 265x97 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 55 RenderInline { TITLE} at (0,0) size 177x1555 RenderInline {title} at (0,0) size 177x15 56 56 RenderText {TEXT} at (10,11) size 177x15 57 57 text run at (10,11) width 177: "contenteditable for Mozilla" … … 68 68 RenderText {TEXT} at (0,0) size 0x0 69 69 RenderBlock {item} at (1,460) size 265x82 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 70 RenderInline { TITLE} at (0,0) size 182x3070 RenderInline {title} at (0,0) size 182x30 71 71 RenderText {TEXT} at (10,11) size 182x30 72 72 text run at (10,11) width 182: "DHTML Timeline/Keyframe" … … 82 82 RenderText {TEXT} at (0,0) size 0x0 83 83 RenderBlock {item} at (1,552) size 265x97 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 84 RenderInline { TITLE} at (0,0) size 157x3084 RenderInline {title} at (0,0) size 157x30 85 85 RenderText {TEXT} at (10,11) size 157x30 86 86 text run at (10,11) width 157: "DynAPI 2.9 and Mozilla" … … 97 97 RenderText {TEXT} at (0,0) size 0x0 98 98 RenderBlock {item} at (1,659) size 265x67 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 99 RenderInline { TITLE} at (0,0) size 154x1599 RenderInline {title} at (0,0) size 154x15 100 100 RenderText {TEXT} at (10,11) size 154x15 101 101 text run at (10,11) width 154: "!lineDraw bookmarklet" … … 110 110 RenderText {TEXT} at (0,0) size 0x0 111 111 RenderBlock {item} at (1,736) size 265x97 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 112 RenderInline { TITLE} at (0,0) size 201x15112 RenderInline {title} at (0,0) size 201x15 113 113 RenderText {TEXT} at (10,11) size 201x15 114 114 text run at (10,11) width 201: "Mozilla, DHTML and DOM links" … … 125 125 RenderText {TEXT} at (0,0) size 0x0 126 126 RenderBlock {item} at (1,843) size 265x67 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 127 RenderInline { TITLE} at (0,0) size 103x15127 RenderInline {title} at (0,0) size 103x15 128 128 RenderText {TEXT} at (10,11) size 103x15 129 129 text run at (10,11) width 103: "Mozilla 1.0 RC2" … … 138 138 RenderText {TEXT} at (0,0) size 0x0 139 139 RenderBlock {item} at (1,920) size 265x97 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 140 RenderInline { TITLE} at (0,0) size 236x30140 RenderInline {title} at (0,0) size 236x30 141 141 RenderText {TEXT} at (10,11) size 236x30 142 142 text run at (10,11) width 236: "javascript: is deprecated. Don't use" … … 153 153 RenderText {TEXT} at (0,0) size 0x0 154 154 RenderBlock {item} at (1,1027) size 265x67 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 155 RenderInline { TITLE} at (0,0) size 176x15155 RenderInline {title} at (0,0) size 176x15 156 156 RenderText {TEXT} at (10,11) size 176x15 157 157 text run at (10,11) width 176: "Conditional Script Loading" … … 164 164 RenderText {TEXT} at (0,0) size 0x0 165 165 RenderBlock {item} at (1,1104) size 265x82 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 166 RenderInline { TITLE} at (0,0) size 115x15166 RenderInline {title} at (0,0) size 115x15 167 167 RenderText {TEXT} at (10,11) size 115x15 168 168 text run at (10,11) width 115: "Stories and Tools" … … 178 178 RenderText {TEXT} at (0,0) size 0x0 179 179 RenderBlock {item} at (1,1196) size 265x97 [bgcolor=#FFFFFF] [border: (1px solid #CCCCCC) none (1px solid #CCCCCC) none] 180 RenderInline { TITLE} at (0,0) size 166x15180 RenderInline {title} at (0,0) size 166x15 181 181 RenderText {TEXT} at (10,11) size 166x15 182 182 text run at (10,11) width 166: "Whole Lotto Gecko Links" -
trunk/LayoutTests/fast/tokenizer/002-expected.txt
r7122 r9639 1 1 layer at (0,0) size 800x600 2 2 RenderCanvas at (0,0) size 800x600 3 layer at (0,0) size 800x 344 RenderBlock {HTML} at (0,0) size 800x 345 RenderBody {BODY} at (8,8) size 784x 183 layer at (0,0) size 800x600 4 RenderBlock {HTML} at (0,0) size 800x600 5 RenderBody {BODY} at (8,8) size 784x584 6 6 RenderText {TEXT} at (0,0) size 315x18 7 7 text run at (0,0) width 315: "you shouldn't see a random chinese character here" -
trunk/LayoutTests/fast/tokenizer/external-script-document-write-expected.txt
r7857 r9639 5 5 RenderBody {BODY} at (8,8) size 784x18 6 6 RenderInline {SPAN} at (0,0) size 0x0 7 RenderText {TEXT} at (0,0) size 2 26x188 text run at (0,0) width 2 26: "This should be a span: [object span]"7 RenderText {TEXT} at (0,0) size 239x18 8 text run at (0,0) width 239: "This should be a span: [object SPAN]" -
trunk/LayoutTests/fast/tokenizer/script_extra_close-expected.txt
r9603 r9639 7 7 text run at (0,0) width 55: "TEST... " 8 8 RenderText {TEXT} at (0,0) size 0x0 9 RenderText {TEXT} at (0,0) size 0x010 9 RenderText {TEXT} at (55,0) size 232x18 11 10 text run at (55,0) width 69: "PASSED. " -
trunk/WebCore/ChangeLog-2005-08-23
r9636 r9639 1 2005-07-09 David Hyatt <hyatt@apple.com> 2 3 Fix for bugzilla bug 3405, replace NodeImpl::Id with a new class, 4 QualifiedName, to represent tag names (for DOM elements and CSS 5 selectors). 6 7 Reviewed by mjs 8 9 * WebCore.pbproj/project.pbxproj: 10 * khtml/css/css_base.cpp: 11 (CSSSelector::anyTagName): 12 (CSSSelector::print): 13 (CSSSelector::specificity): 14 (CSSSelector::selectorText): 15 * khtml/css/css_base.h: 16 (DOM::CSSNamespace::uri): 17 (DOM::CSSNamespace::prefix): 18 (DOM::CSSNamespace::namespaceForPrefix): 19 (DOM::CSSSelector::CSSSelector): 20 (DOM::CSSSelector::hasTag): 21 * khtml/css/css_ruleimpl.cpp: 22 * khtml/css/css_ruleimpl.h: 23 * khtml/css/css_stylesheetimpl.cpp: 24 (CSSStyleSheetImpl::addNamespace): 25 (CSSStyleSheetImpl::determineNamespace): 26 * khtml/css/css_stylesheetimpl.h: 27 * khtml/css/cssparser.cpp: 28 (CSSParser::CSSParser): 29 (CSSParser::parseSheet): 30 * khtml/css/cssparser.h: 31 * khtml/css/cssstyleselector.cpp: 32 (khtml::CSSStyleSelector::matchRules): 33 (khtml::CSSStyleSelector::matchRulesForList): 34 (khtml::CSSStyleSelector::canShareStyleWithElement): 35 (khtml::CSSStyleSelector::adjustRenderStyle): 36 (khtml::CSSStyleSelector::checkSelector): 37 (khtml::CSSStyleSelector::checkOneSelector): 38 (khtml::CSSRuleSet::addRule): 39 * khtml/css/cssstyleselector.h: 40 (khtml::CSSRuleSet::getTagRules): 41 * khtml/css/parser.y: 42 * khtml/dom/css_stylesheet.cpp: 43 (LinkStyle::operator = ): 44 (LinkStyle::sheet): 45 * khtml/dom/dom_element.cpp: 46 (Element::tagName): 47 * khtml/dom/dom_node.cpp: 48 (Node::namespaceURI): 49 (Node::setPrefix): 50 * khtml/dom/dom_node.h: 51 * khtml/dom/html_base.cpp: 52 (HTMLBodyElement::operator = ): 53 (HTMLFrameElement::operator = ): 54 (HTMLIFrameElement::operator = ): 55 (HTMLFrameSetElement::operator = ): 56 (HTMLHeadElement::operator = ): 57 (HTMLHtmlElement::operator = ): 58 * khtml/dom/html_block.cpp: 59 (HTMLBlockquoteElement::operator = ): 60 (HTMLDivElement::operator = ): 61 (HTMLHRElement::operator = ): 62 (HTMLHeadingElement::operator = ): 63 (HTMLParagraphElement::operator = ): 64 (HTMLPreElement::operator = ): 65 * khtml/dom/html_element.cpp: 66 (HTMLElement::assignOther): 67 * khtml/dom/html_element.h: 68 * khtml/dom/html_form.cpp: 69 (HTMLButtonElement::operator = ): 70 (HTMLFieldSetElement::operator = ): 71 (HTMLFormElement::operator = ): 72 (HTMLInputElement::operator = ): 73 (HTMLLabelElement::operator = ): 74 (HTMLLegendElement::operator = ): 75 (HTMLOptGroupElement::operator = ): 76 (HTMLSelectElement::operator = ): 77 (HTMLTextAreaElement::operator = ): 78 (HTMLOptionElement::operator = ): 79 (HTMLIsIndexElement::operator = ): 80 * khtml/dom/html_head.cpp: 81 (HTMLBaseElement::operator = ): 82 (HTMLLinkElement::operator = ): 83 (HTMLMetaElement::operator = ): 84 (HTMLScriptElement::operator = ): 85 (HTMLStyleElement::operator = ): 86 (HTMLTitleElement::operator = ): 87 * khtml/dom/html_image.cpp: 88 (HTMLAreaElement::operator = ): 89 (HTMLImageElement::operator = ): 90 (HTMLMapElement::operator = ): 91 * khtml/dom/html_inline.cpp: 92 (HTMLAnchorElement::operator = ): 93 (HTMLBRElement::operator = ): 94 (HTMLFontElement::operator = ): 95 (HTMLModElement::HTMLModElement): 96 (HTMLModElement::operator = ): 97 (HTMLQuoteElement::HTMLQuoteElement): 98 (HTMLQuoteElement::operator = ): 99 * khtml/dom/html_inline.h: 100 * khtml/dom/html_list.cpp: 101 (HTMLDListElement::operator = ): 102 (HTMLDirectoryElement::operator = ): 103 (HTMLLIElement::operator = ): 104 (HTMLMenuElement::operator = ): 105 (HTMLOListElement::operator = ): 106 (HTMLUListElement::operator = ): 107 * khtml/dom/html_misc.cpp: 108 (HTMLBaseFontElement::operator = ): 109 * khtml/dom/html_object.cpp: 110 (DOM::HTMLAppletElement::operator = ): 111 (DOM::HTMLObjectElement::operator = ): 112 (DOM::HTMLParamElement::operator = ): 113 * khtml/dom/html_table.cpp: 114 (HTMLTableCaptionElement::operator = ): 115 (HTMLTableCellElement::operator = ): 116 (HTMLTableColElement::operator = ): 117 (HTMLTableElement::operator = ): 118 (HTMLTableRowElement::operator = ): 119 (HTMLTableSectionElement::operator = ): 120 * khtml/ecma/kjs_css.cpp: 121 (KJS::DOMStyleSheetList::tryGet): 122 * khtml/ecma/kjs_dom.cpp: 123 (KJS::DOMNode::putValue): 124 (KJS::DOMElement::tryGet): 125 (KJS::getRuntimeObject): 126 * khtml/ecma/kjs_html.cpp: 127 (KJS::HTMLDocument::tryGet): 128 (KJS::KJS::HTMLDocument::putValue): 129 (KJS::KJS::HTMLElement::classInfo): 130 (KJS::): 131 (KJS::HTMLElement::getSetInfo): 132 (KJS::KJS::HTMLElement::tryGet): 133 (KJS::KJS::HTMLElement::implementsCall): 134 (KJS::KJS::HTMLElement::call): 135 (KJS::HTMLElement::htmlGetter): 136 (KJS::HTMLElement::headGetter): 137 (KJS::HTMLElement::linkGetter): 138 (KJS::HTMLElement::titleGetter): 139 (KJS::HTMLElement::metaGetter): 140 (KJS::HTMLElement::baseGetter): 141 (KJS::HTMLElement::isIndexGetter): 142 (KJS::HTMLElement::styleGetter): 143 (KJS::HTMLElement::bodyGetter): 144 (KJS::HTMLElement::formGetter): 145 (KJS::HTMLElement::selectGetter): 146 (KJS::HTMLElement::optGroupGetter): 147 (KJS::HTMLElement::optionGetter): 148 (KJS::getInputSelectionStart): 149 (KJS::getInputSelectionEnd): 150 (KJS::HTMLElement::inputGetter): 151 (KJS::HTMLElement::textAreaGetter): 152 (KJS::HTMLElement::buttonGetter): 153 (KJS::HTMLElement::labelGetter): 154 (KJS::HTMLElement::fieldSetGetter): 155 (KJS::HTMLElement::legendGetter): 156 (KJS::HTMLElement::uListGetter): 157 (KJS::HTMLElement::oListGetter): 158 (KJS::HTMLElement::dListGetter): 159 (KJS::HTMLElement::dirGetter): 160 (KJS::HTMLElement::menuGetter): 161 (KJS::HTMLElement::liGetter): 162 (KJS::HTMLElement::divGetter): 163 (KJS::HTMLElement::paragraphGetter): 164 (KJS::HTMLElement::headingGetter): 165 (KJS::HTMLElement::blockQuoteGetter): 166 (KJS::HTMLElement::quoteGetter): 167 (KJS::HTMLElement::preGetter): 168 (KJS::HTMLElement::brGetter): 169 (KJS::HTMLElement::baseFontGetter): 170 (KJS::HTMLElement::fontGetter): 171 (KJS::HTMLElement::hrGetter): 172 (KJS::HTMLElement::modGetter): 173 (KJS::HTMLElement::anchorGetter): 174 (KJS::HTMLElement::imageGetter): 175 (KJS::HTMLElement::objectGetter): 176 (KJS::HTMLElement::paramGetter): 177 (KJS::HTMLElement::appletGetter): 178 (KJS::HTMLElement::mapGetter): 179 (KJS::HTMLElement::areaGetter): 180 (KJS::HTMLElement::scriptGetter): 181 (KJS::HTMLElement::tableGetter): 182 (KJS::HTMLElement::tableCaptionGetter): 183 (KJS::HTMLElement::tableColGetter): 184 (KJS::HTMLElement::tableSectionGetter): 185 (KJS::HTMLElement::tableRowGetter): 186 (KJS::HTMLElement::tableCellGetter): 187 (KJS::HTMLElement::frameSetGetter): 188 (KJS::HTMLElement::frameGetter): 189 (KJS::HTMLElement::iFrameGetter): 190 (KJS::HTMLElement::marqueeGetter): 191 (KJS::HTMLElement::getValueProperty): 192 (KJS::KJS::HTMLElement::hasOwnProperty): 193 (KJS::KJS::HTMLElement::toString): 194 (KJS::getForm): 195 (KJS::KJS::HTMLElement::pushEventHandlerScope): 196 (KJS::KJS::HTMLElementFunction::tryCall): 197 (KJS::KJS::HTMLElement::tryPut): 198 (KJS::HTMLElement::htmlSetter): 199 (KJS::HTMLElement::headSetter): 200 (KJS::HTMLElement::linkSetter): 201 (KJS::HTMLElement::titleSetter): 202 (KJS::HTMLElement::metaSetter): 203 (KJS::HTMLElement::baseSetter): 204 (KJS::HTMLElement::isIndexSetter): 205 (KJS::HTMLElement::styleSetter): 206 (KJS::HTMLElement::bodySetter): 207 (KJS::HTMLElement::formSetter): 208 (KJS::HTMLElement::selectSetter): 209 (KJS::HTMLElement::optGroupSetter): 210 (KJS::HTMLElement::optionSetter): 211 (KJS::HTMLElement::inputSetter): 212 (KJS::HTMLElement::textAreaSetter): 213 (KJS::HTMLElement::buttonSetter): 214 (KJS::HTMLElement::labelSetter): 215 (KJS::HTMLElement::fieldSetSetter): 216 (KJS::HTMLElement::legendSetter): 217 (KJS::HTMLElement::uListSetter): 218 (KJS::HTMLElement::oListSetter): 219 (KJS::HTMLElement::dListSetter): 220 (KJS::HTMLElement::dirSetter): 221 (KJS::HTMLElement::menuSetter): 222 (KJS::HTMLElement::liSetter): 223 (KJS::HTMLElement::divSetter): 224 (KJS::HTMLElement::paragraphSetter): 225 (KJS::HTMLElement::headingSetter): 226 (KJS::HTMLElement::blockQuoteSetter): 227 (KJS::HTMLElement::quoteSetter): 228 (KJS::HTMLElement::preSetter): 229 (KJS::HTMLElement::brSetter): 230 (KJS::HTMLElement::baseFontSetter): 231 (KJS::HTMLElement::fontSetter): 232 (KJS::HTMLElement::hrSetter): 233 (KJS::HTMLElement::modSetter): 234 (KJS::HTMLElement::anchorSetter): 235 (KJS::HTMLElement::imageSetter): 236 (KJS::HTMLElement::objectSetter): 237 (KJS::HTMLElement::paramSetter): 238 (KJS::HTMLElement::appletSetter): 239 (KJS::HTMLElement::mapSetter): 240 (KJS::HTMLElement::areaSetter): 241 (KJS::HTMLElement::scriptSetter): 242 (KJS::HTMLElement::tableSetter): 243 (KJS::HTMLElement::tableCaptionSetter): 244 (KJS::HTMLElement::tableColSetter): 245 (KJS::HTMLElement::tableSectionSetter): 246 (KJS::HTMLElement::tableRowSetter): 247 (KJS::HTMLElement::tableCellSetter): 248 (KJS::HTMLElement::frameSetSetter): 249 (KJS::HTMLElement::frameSetter): 250 (KJS::HTMLElement::iFrameSetter): 251 (KJS::HTMLElement::marqueeSetter): 252 (KJS::HTMLElement::putValue): 253 (KJS::toHTMLTableCaptionElement): 254 (KJS::toHTMLTableSectionElement): 255 (KJS::KJS::HTMLCollection::tryGet): 256 (KJS::KJS::HTMLSelectCollection::tryPut): 257 * khtml/ecma/kjs_html.h: 258 * khtml/ecma/kjs_window.cpp: 259 * khtml/editing/apply_style_command.cpp: 260 (khtml::isStyleSpan): 261 (khtml::isEmptyStyleSpan): 262 (khtml::isEmptyFontTag): 263 (khtml::createFontElement): 264 (khtml::createStyleSpanElement): 265 (khtml::ApplyStyleCommand::applyInlineStyle): 266 (khtml::ApplyStyleCommand::isHTMLStyleNode): 267 (khtml::ApplyStyleCommand::removeHTMLFontStyle): 268 (khtml::areIdenticalElements): 269 (khtml::ApplyStyleCommand::mergeEndWithNextIfIdentical): 270 (khtml::ApplyStyleCommand::addInlineStyleIfNeeded): 271 * khtml/editing/break_blockquote_command.cpp: 272 (khtml::BreakBlockquoteCommand::doApply): 273 * khtml/editing/composite_edit_command.cpp: 274 (khtml::CompositeEditCommand::insertNodeBefore): 275 (khtml::CompositeEditCommand::insertNodeAfter): 276 (khtml::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary): 277 (khtml::createBlockPlaceholderElement): 278 * khtml/editing/delete_selection_command.cpp: 279 (khtml::isListStructureNode): 280 (khtml::DeleteSelectionCommand::handleSpecialCaseBRDelete): 281 (khtml::DeleteSelectionCommand::handleGeneralDelete): 282 (khtml::DeleteSelectionCommand::moveNodesAfterNode): 283 * khtml/editing/htmlediting.cpp: 284 (khtml::isSpecialElement): 285 (khtml::createDefaultParagraphElement): 286 (khtml::createBreakElement): 287 (khtml::isMailBlockquote): 288 * khtml/editing/insert_line_break_command.cpp: 289 (khtml::InsertLineBreakCommand::doApply): 290 * khtml/editing/insert_paragraph_separator_command.cpp: 291 (khtml::InsertParagraphSeparatorCommand::doApply): 292 * khtml/editing/markup.cpp: 293 (khtml::startMarkup): 294 (khtml::endMarkup): 295 (khtml::markup): 296 (khtml::createMarkup): 297 (khtml::createFragmentFromText): 298 * khtml/editing/replace_selection_command.cpp: 299 (khtml::isProbablyBlock): 300 (khtml::isProbablyTableStructureNode): 301 (khtml::ReplacementFragment::isInterchangeNewlineNode): 302 (khtml::ReplacementFragment::removeStyleNodes): 303 (khtml::ReplaceSelectionCommand::doApply): 304 (khtml::ReplaceSelectionCommand::updateNodesInserted): 305 * khtml/editing/selection.cpp: 306 (khtml::Selection::debugRenderer): 307 * khtml/editing/visible_position.cpp: 308 (khtml::VisiblePosition::init): 309 (khtml::VisiblePosition::isCandidate): 310 (khtml::VisiblePosition::isAtomicNode): 311 * khtml/editing/visible_text.cpp: 312 (khtml::TextIterator::handleNonTextNode): 313 (khtml::TextIterator::exitNode): 314 (khtml::SimplifiedBackwardsTextIterator::handleNonTextNode): 315 * khtml/editing/visible_units.cpp: 316 (khtml::endOfLine): 317 * khtml/html/dtd.cpp: Removed. 318 * khtml/html/dtd.h: Removed. 319 * khtml/html/html_baseimpl.cpp: 320 (HTMLBodyElementImpl::HTMLBodyElementImpl): 321 (HTMLFrameElementImpl::HTMLFrameElementImpl): 322 (HTMLFrameElementImpl::init): 323 (HTMLFrameElementImpl::attach): 324 (HTMLFrameSetElementImpl::HTMLFrameSetElementImpl): 325 (HTMLFrameSetElementImpl::checkDTD): 326 (HTMLFrameSetElementImpl::attach): 327 (HTMLHeadElementImpl::HTMLHeadElementImpl): 328 (HTMLHeadElementImpl::checkDTD): 329 (HTMLHtmlElementImpl::HTMLHtmlElementImpl): 330 (HTMLHtmlElementImpl::checkDTD): 331 (HTMLIFrameElementImpl::HTMLIFrameElementImpl): 332 * khtml/html/html_baseimpl.h: 333 (DOM::HTMLBodyElementImpl::endTagRequirement): 334 (DOM::HTMLBodyElementImpl::tagPriority): 335 (DOM::HTMLFrameElementImpl::endTagRequirement): 336 (DOM::HTMLFrameElementImpl::tagPriority): 337 (DOM::HTMLFrameSetElementImpl::endTagRequirement): 338 (DOM::HTMLFrameSetElementImpl::tagPriority): 339 (DOM::HTMLHeadElementImpl::endTagRequirement): 340 (DOM::HTMLHeadElementImpl::tagPriority): 341 (DOM::HTMLHtmlElementImpl::endTagRequirement): 342 (DOM::HTMLHtmlElementImpl::tagPriority): 343 (DOM::HTMLIFrameElementImpl::endTagRequirement): 344 (DOM::HTMLIFrameElementImpl::tagPriority): 345 * khtml/html/html_blockimpl.cpp: 346 (HTMLBlockquoteElementImpl::HTMLBlockquoteElementImpl): 347 (HTMLDivElementImpl::HTMLDivElementImpl): 348 (HTMLHRElementImpl::HTMLHRElementImpl): 349 (HTMLHeadingElementImpl::HTMLHeadingElementImpl): 350 (HTMLHeadingElementImpl::checkDTD): 351 (HTMLParagraphElementImpl::HTMLParagraphElementImpl): 352 (HTMLParagraphElementImpl::checkDTD): 353 (HTMLPreElementImpl::HTMLPreElementImpl): 354 (HTMLMarqueeElementImpl::HTMLMarqueeElementImpl): 355 (HTMLMarqueeElementImpl::parseMappedAttribute): 356 * khtml/html/html_blockimpl.h: 357 (DOM::HTMLBlockquoteElementImpl::endTagRequirement): 358 (DOM::HTMLBlockquoteElementImpl::tagPriority): 359 (DOM::HTMLDivElementImpl::endTagRequirement): 360 (DOM::HTMLDivElementImpl::tagPriority): 361 (DOM::HTMLHRElementImpl::endTagRequirement): 362 (DOM::HTMLHRElementImpl::tagPriority): 363 (DOM::HTMLHeadingElementImpl::endTagRequirement): 364 (DOM::HTMLHeadingElementImpl::tagPriority): 365 (DOM::HTMLParagraphElementImpl::endTagRequirement): 366 (DOM::HTMLParagraphElementImpl::tagPriority): 367 (DOM::HTMLPreElementImpl::endTagRequirement): 368 (DOM::HTMLPreElementImpl::tagPriority): 369 (DOM::HTMLMarqueeElementImpl::endTagRequirement): 370 (DOM::HTMLMarqueeElementImpl::tagPriority): 371 * khtml/html/html_canvasimpl.cpp: 372 (HTMLCanvasElementImpl::HTMLCanvasElementImpl): 373 * khtml/html/html_canvasimpl.h: 374 * khtml/html/html_documentimpl.cpp: 375 (DOM::HTMLDocumentImpl::childAllowed): 376 (DOM::HTMLDocumentImpl::createElement): 377 * khtml/html/html_documentimpl.h: 378 * khtml/html/html_elementimpl.cpp: 379 (HTMLElementImpl::HTMLElementImpl): 380 (HTMLElementImpl::nodeName): 381 (HTMLElementImpl::endTagRequirement): 382 (HTMLElementImpl::tagPriority): 383 (HTMLElementImpl::cloneNode): 384 (HTMLElementImpl::createContextualFragment): 385 (HTMLElementImpl::setInnerHTML): 386 (HTMLElementImpl::setOuterHTML): 387 (HTMLElementImpl::setInnerText): 388 (HTMLElementImpl::setOuterText): 389 (HTMLElementImpl::toString): 390 (HTMLElementImpl::id): 391 (HTMLElementImpl::childAllowed): 392 (HTMLElementImpl::isRecognizedTagName): 393 (inlineTagList): 394 (blockTagList): 395 (HTMLElementImpl::inEitherTagList): 396 (HTMLElementImpl::inInlineTagList): 397 (HTMLElementImpl::inBlockTagList): 398 (HTMLElementImpl::checkDTD): 399 * khtml/html/html_elementimpl.h: 400 (DOM::): 401 * khtml/html/html_formimpl.cpp: 402 (DOM::HTMLFormElementImpl::HTMLFormElementImpl): 403 (DOM::HTMLFormElementImpl::submitClick): 404 (DOM::HTMLFormElementImpl::formData): 405 (DOM::HTMLFormElementImpl::submit): 406 (DOM::HTMLFormElementImpl::radioClicked): 407 (DOM::HTMLGenericFormElementImpl::HTMLGenericFormElementImpl): 408 (DOM::HTMLGenericFormElementImpl::getForm): 409 (DOM::HTMLButtonElementImpl::HTMLButtonElementImpl): 410 (DOM::HTMLFieldSetElementImpl::HTMLFieldSetElementImpl): 411 (DOM::HTMLFieldSetElementImpl::checkDTD): 412 (DOM::HTMLFieldSetElementImpl::isFocusable): 413 (DOM::HTMLInputElementImpl::HTMLInputElementImpl): 414 (DOM::HTMLInputElementImpl::init): 415 (DOM::HTMLLabelElementImpl::HTMLLabelElementImpl): 416 (DOM::HTMLLabelElementImpl::form): 417 (DOM::HTMLLegendElementImpl::HTMLLegendElementImpl): 418 (DOM::HTMLLegendElementImpl::formElement): 419 (DOM::HTMLSelectElementImpl::HTMLSelectElementImpl): 420 (DOM::HTMLSelectElementImpl::init): 421 (DOM::HTMLSelectElementImpl::checkDTD): 422 (DOM::HTMLSelectElementImpl::selectedIndex): 423 (DOM::HTMLSelectElementImpl::setSelectedIndex): 424 (DOM::HTMLSelectElementImpl::length): 425 (DOM::HTMLSelectElementImpl::add): 426 (DOM::HTMLSelectElementImpl::value): 427 (DOM::HTMLSelectElementImpl::setValue): 428 (DOM::HTMLSelectElementImpl::state): 429 (DOM::HTMLSelectElementImpl::restoreState): 430 (DOM::HTMLSelectElementImpl::appendFormData): 431 (DOM::HTMLSelectElementImpl::optionToListIndex): 432 (DOM::HTMLSelectElementImpl::listToOptionIndex): 433 (DOM::HTMLSelectElementImpl::recalcListItems): 434 (DOM::HTMLSelectElementImpl::reset): 435 (DOM::HTMLSelectElementImpl::notifyOptionSelected): 436 (DOM::HTMLKeygenElementImpl::HTMLKeygenElementImpl): 437 (DOM::HTMLOptGroupElementImpl::HTMLOptGroupElementImpl): 438 (DOM::HTMLOptGroupElementImpl::recalcSelectOptions): 439 (DOM::HTMLOptionElementImpl::HTMLOptionElementImpl): 440 (DOM::HTMLOptionElementImpl::index): 441 (DOM::HTMLOptionElementImpl::getSelect): 442 (DOM::HTMLTextAreaElementImpl::HTMLTextAreaElementImpl): 443 (DOM::HTMLIsIndexElementImpl::HTMLIsIndexElementImpl): 444 * khtml/html/html_formimpl.h: 445 (DOM::HTMLFormElementImpl::endTagRequirement): 446 (DOM::HTMLFormElementImpl::tagPriority): 447 (DOM::HTMLGenericFormElementImpl::endTagRequirement): 448 (DOM::HTMLGenericFormElementImpl::tagPriority): 449 (DOM::HTMLFieldSetElementImpl::tagPriority): 450 (DOM::HTMLInputElementImpl::endTagRequirement): 451 (DOM::HTMLInputElementImpl::tagPriority): 452 (DOM::HTMLLabelElementImpl::tagPriority): 453 (DOM::HTMLSelectElementImpl::tagPriority): 454 (DOM::HTMLKeygenElementImpl::tagPriority): 455 (DOM::HTMLOptGroupElementImpl::checkDTD): 456 (DOM::HTMLOptionElementImpl::endTagRequirement): 457 (DOM::HTMLOptionElementImpl::tagPriority): 458 (DOM::HTMLOptionElementImpl::checkDTD): 459 (DOM::HTMLTextAreaElementImpl::checkDTD): 460 (DOM::HTMLTextAreaElementImpl::cols): 461 (DOM::HTMLIsIndexElementImpl::endTagRequirement): 462 (DOM::HTMLIsIndexElementImpl::tagPriority): 463 * khtml/html/html_headimpl.cpp: 464 (HTMLBaseElementImpl::HTMLBaseElementImpl): 465 (HTMLLinkElementImpl::HTMLLinkElementImpl): 466 (HTMLMetaElementImpl::HTMLMetaElementImpl): 467 (HTMLScriptElementImpl::HTMLScriptElementImpl): 468 (HTMLStyleElementImpl::HTMLStyleElementImpl): 469 (HTMLTitleElementImpl::HTMLTitleElementImpl): 470 * khtml/html/html_headimpl.h: 471 (DOM::HTMLBaseElementImpl::endTagRequirement): 472 (DOM::HTMLBaseElementImpl::tagPriority): 473 (DOM::HTMLLinkElementImpl::endTagRequirement): 474 (DOM::HTMLLinkElementImpl::tagPriority): 475 (DOM::HTMLMetaElementImpl::endTagRequirement): 476 (DOM::HTMLMetaElementImpl::tagPriority): 477 (DOM::HTMLScriptElementImpl::endTagRequirement): 478 (DOM::HTMLScriptElementImpl::tagPriority): 479 (DOM::HTMLScriptElementImpl::checkDTD): 480 (DOM::HTMLStyleElementImpl::endTagRequirement): 481 (DOM::HTMLStyleElementImpl::tagPriority): 482 (DOM::HTMLStyleElementImpl::checkDTD): 483 (DOM::HTMLTitleElementImpl::checkDTD): 484 * khtml/html/html_imageimpl.cpp: 485 (HTMLImageLoader::updateFromElement): 486 (HTMLImageElementImpl::HTMLImageElementImpl): 487 (HTMLImageElementImpl::~HTMLImageElementImpl): 488 (HTMLMapElementImpl::HTMLMapElementImpl): 489 (HTMLMapElementImpl::checkDTD): 490 (HTMLMapElementImpl::mapMouseEvent): 491 (HTMLAreaElementImpl::HTMLAreaElementImpl): 492 * khtml/html/html_imageimpl.h: 493 (DOM::HTMLImageElementImpl::endTagRequirement): 494 (DOM::HTMLImageElementImpl::tagPriority): 495 (DOM::HTMLAreaElementImpl::endTagRequirement): 496 (DOM::HTMLAreaElementImpl::tagPriority): 497 (DOM::HTMLMapElementImpl::endTagRequirement): 498 (DOM::HTMLMapElementImpl::tagPriority): 499 * khtml/html/html_inlineimpl.cpp: 500 (DOM::HTMLAnchorElementImpl::HTMLAnchorElementImpl): 501 (DOM::HTMLAnchorElementImpl::defaultEventHandler): 502 (DOM::HTMLBRElementImpl::HTMLBRElementImpl): 503 (DOM::HTMLFontElementImpl::HTMLFontElementImpl): 504 (DOM::HTMLModElementImpl::HTMLModElementImpl): 505 (DOM::HTMLQuoteElementImpl::HTMLQuoteElementImpl): 506 * khtml/html/html_inlineimpl.h: 507 (DOM::HTMLAnchorElementImpl::endTagRequirement): 508 (DOM::HTMLAnchorElementImpl::tagPriority): 509 (DOM::HTMLBRElementImpl::endTagRequirement): 510 (DOM::HTMLBRElementImpl::tagPriority): 511 (DOM::HTMLFontElementImpl::endTagRequirement): 512 (DOM::HTMLFontElementImpl::tagPriority): 513 (DOM::HTMLModElementImpl::endTagRequirement): 514 (DOM::HTMLModElementImpl::tagPriority): 515 (DOM::HTMLQuoteElementImpl::endTagRequirement): 516 (DOM::HTMLQuoteElementImpl::tagPriority): 517 * khtml/html/html_listimpl.cpp: 518 (DOM::HTMLOListElementImpl::parseMappedAttribute): 519 (DOM::HTMLLIElementImpl::attach): 520 (DOM::HTMLLIElementImpl::setValue): 521 * khtml/html/html_listimpl.h: 522 (DOM::HTMLUListElementImpl::HTMLUListElementImpl): 523 (DOM::HTMLUListElementImpl::endTagRequirement): 524 (DOM::HTMLUListElementImpl::tagPriority): 525 (DOM::HTMLDirectoryElementImpl::HTMLDirectoryElementImpl): 526 (DOM::HTMLDirectoryElementImpl::endTagRequirement): 527 (DOM::HTMLDirectoryElementImpl::tagPriority): 528 (DOM::HTMLMenuElementImpl::HTMLMenuElementImpl): 529 (DOM::HTMLMenuElementImpl::endTagRequirement): 530 (DOM::HTMLMenuElementImpl::tagPriority): 531 (DOM::HTMLOListElementImpl::HTMLOListElementImpl): 532 (DOM::HTMLOListElementImpl::endTagRequirement): 533 (DOM::HTMLOListElementImpl::tagPriority): 534 (DOM::HTMLLIElementImpl::HTMLLIElementImpl): 535 (DOM::HTMLLIElementImpl::endTagRequirement): 536 (DOM::HTMLLIElementImpl::tagPriority): 537 (DOM::HTMLDListElementImpl::HTMLDListElementImpl): 538 (DOM::HTMLDListElementImpl::endTagRequirement): 539 (DOM::HTMLDListElementImpl::tagPriority): 540 * khtml/html/html_miscimpl.cpp: 541 (DOM::HTMLBaseFontElementImpl::HTMLBaseFontElementImpl): 542 (DOM::HTMLCollectionImpl::traverseNextItem): 543 (DOM::HTMLCollectionImpl::checkForNameMatch): 544 (DOM::HTMLCollectionImpl::updateNameCache): 545 (DOM::HTMLFormCollectionImpl::getNamedFormItem): 546 (DOM::HTMLFormCollectionImpl::updateNameCache): 547 * khtml/html/html_miscimpl.h: 548 (DOM::HTMLBaseFontElementImpl::endTagRequirement): 549 (DOM::HTMLBaseFontElementImpl::tagPriority): 550 * khtml/html/html_objectimpl.cpp: 551 (DOM::HTMLAppletElementImpl::HTMLAppletElementImpl): 552 (DOM::HTMLAppletElementImpl::checkDTD): 553 (DOM::HTMLEmbedElementImpl::HTMLEmbedElementImpl): 554 (DOM::HTMLEmbedElementImpl::checkDTD): 555 (DOM::HTMLEmbedElementImpl::rendererIsNeeded): 556 (DOM::HTMLObjectElementImpl::HTMLObjectElementImpl): 557 (DOM::HTMLObjectElementImpl::checkDTD): 558 (DOM::HTMLObjectElementImpl::form): 559 (DOM::HTMLParamElementImpl::HTMLParamElementImpl): 560 * khtml/html/html_objectimpl.h: 561 (DOM::HTMLAppletElementImpl::endTagRequirement): 562 (DOM::HTMLAppletElementImpl::tagPriority): 563 (DOM::HTMLEmbedElementImpl::endTagRequirement): 564 (DOM::HTMLEmbedElementImpl::tagPriority): 565 (DOM::HTMLObjectElementImpl::endTagRequirement): 566 (DOM::HTMLObjectElementImpl::tagPriority): 567 (DOM::HTMLParamElementImpl::endTagRequirement): 568 (DOM::HTMLParamElementImpl::tagPriority): 569 * khtml/html/html_tableimpl.cpp: 570 (DOM::HTMLTableElementImpl::HTMLTableElementImpl): 571 (DOM::HTMLTableElementImpl::checkDTD): 572 (DOM::HTMLTableElementImpl::createTHead): 573 (DOM::HTMLTableElementImpl::createTFoot): 574 (DOM::HTMLTableElementImpl::insertRow): 575 (DOM::HTMLTableElementImpl::deleteRow): 576 (DOM::HTMLTableElementImpl::addChild): 577 (DOM::HTMLTableSectionElementImpl::HTMLTableSectionElementImpl): 578 (DOM::HTMLTableSectionElementImpl::checkDTD): 579 (DOM::HTMLTableSectionElementImpl::addChild): 580 (DOM::HTMLTableSectionElementImpl::numRows): 581 (DOM::HTMLTableRowElementImpl::checkDTD): 582 (DOM::HTMLTableRowElementImpl::addChild): 583 (DOM::HTMLTableRowElementImpl::rowIndex): 584 (DOM::HTMLTableRowElementImpl::sectionRowIndex): 585 (DOM::HTMLTableRowElementImpl::insertCell): 586 (DOM::HTMLTableCellElementImpl::HTMLTableCellElementImpl): 587 (DOM::HTMLTableCellElementImpl::cellIndex): 588 (DOM::HTMLTableCellElementImpl::additionalAttributeStyleDecl): 589 (DOM::HTMLTableColElementImpl::HTMLTableColElementImpl): 590 * khtml/html/html_tableimpl.h: 591 (DOM::HTMLTableElementImpl::endTagRequirement): 592 (DOM::HTMLTableElementImpl::tagPriority): 593 (DOM::HTMLTablePartElementImpl::HTMLTablePartElementImpl): 594 (DOM::HTMLTableSectionElementImpl::endTagRequirement): 595 (DOM::HTMLTableSectionElementImpl::tagPriority): 596 (DOM::HTMLTableRowElementImpl::HTMLTableRowElementImpl): 597 (DOM::HTMLTableRowElementImpl::endTagRequirement): 598 (DOM::HTMLTableRowElementImpl::tagPriority): 599 (DOM::HTMLTableCellElementImpl::endTagRequirement): 600 (DOM::HTMLTableCellElementImpl::tagPriority): 601 (DOM::HTMLTableColElementImpl::endTagRequirement): 602 (DOM::HTMLTableColElementImpl::tagPriority): 603 (DOM::HTMLTableColElementImpl::checkDTD): 604 (DOM::HTMLTableCaptionElementImpl::HTMLTableCaptionElementImpl): 605 (DOM::HTMLTableCaptionElementImpl::endTagRequirement): 606 (DOM::HTMLTableCaptionElementImpl::tagPriority): 607 * khtml/html/htmlfactory.cpp: Added. 608 (DOM::htmlConstructor): 609 (DOM::headConstructor): 610 (DOM::bodyConstructor): 611 (DOM::baseConstructor): 612 (DOM::linkConstructor): 613 (DOM::metaConstructor): 614 (DOM::styleConstructor): 615 (DOM::titleConstructor): 616 (DOM::frameConstructor): 617 (DOM::framesetConstructor): 618 (DOM::iframeConstructor): 619 (DOM::formConstructor): 620 (DOM::buttonConstructor): 621 (DOM::inputConstructor): 622 (DOM::isindexConstructor): 623 (DOM::fieldsetConstructor): 624 (DOM::labelConstructor): 625 (DOM::legendConstructor): 626 (DOM::optgroupConstructor): 627 (DOM::optionConstructor): 628 (DOM::selectConstructor): 629 (DOM::textareaConstructor): 630 (DOM::dlConstructor): 631 (DOM::ulConstructor): 632 (DOM::olConstructor): 633 (DOM::dirConstructor): 634 (DOM::menuConstructor): 635 (DOM::liConstructor): 636 (DOM::blockquoteConstructor): 637 (DOM::divConstructor): 638 (DOM::headingConstructor): 639 (DOM::hrConstructor): 640 (DOM::paragraphConstructor): 641 (DOM::preConstructor): 642 (DOM::basefontConstructor): 643 (DOM::fontConstructor): 644 (DOM::modConstructor): 645 (DOM::anchorConstructor): 646 (DOM::imageConstructor): 647 (DOM::mapConstructor): 648 (DOM::areaConstructor): 649 (DOM::canvasConstructor): 650 (DOM::appletConstructor): 651 (DOM::embedConstructor): 652 (DOM::objectConstructor): 653 (DOM::paramConstructor): 654 (DOM::scriptConstructor): 655 (DOM::tableConstructor): 656 (DOM::tableCaptionConstructor): 657 (DOM::tableColConstructor): 658 (DOM::tableRowConstructor): 659 (DOM::tableCellConstructor): 660 (DOM::tableSectionConstructor): 661 (DOM::brConstructor): 662 (DOM::quoteConstructor): 663 (DOM::marqueeConstructor): 664 (DOM::HTMLElementFactory::createHTMLElement): 665 * khtml/html/htmlfactory.h: Added. 666 * khtml/html/htmlnames.cpp: 667 (DOM::HTMLNames::init): 668 * khtml/html/htmlnames.h: 669 (DOM::HTMLNames::xhtmlNamespaceURI): 670 * khtml/html/htmlparser.cpp: 671 (HTMLStackElem::HTMLStackElem): 672 (HTMLParser::HTMLParser): 673 (HTMLParser::~HTMLParser): 674 (HTMLParser::reset): 675 (HTMLParser::setCurrent): 676 (HTMLParser::parseToken): 677 (isTableSection): 678 (isTablePart): 679 (isTableRelated): 680 (HTMLParser::insertNode): 681 (HTMLParser::handleError): 682 (HTMLParser::textCreateErrorCheck): 683 (HTMLParser::commentCreateErrorCheck): 684 (HTMLParser::headCreateErrorCheck): 685 (HTMLParser::bodyCreateErrorCheck): 686 (HTMLParser::framesetCreateErrorCheck): 687 (HTMLParser::iframeCreateErrorCheck): 688 (HTMLParser::formCreateErrorCheck): 689 (HTMLParser::isindexCreateErrorCheck): 690 (HTMLParser::selectCreateErrorCheck): 691 (HTMLParser::ddCreateErrorCheck): 692 (HTMLParser::dtCreateErrorCheck): 693 (HTMLParser::nestedCreateErrorCheck): 694 (HTMLParser::nestedStyleCreateErrorCheck): 695 (HTMLParser::tableCellCreateErrorCheck): 696 (HTMLParser::tableSectionCreateErrorCheck): 697 (HTMLParser::noembedCreateErrorCheck): 698 (HTMLParser::noframesCreateErrorCheck): 699 (HTMLParser::noscriptCreateErrorCheck): 700 (HTMLParser::nolayerCreateErrorCheck): 701 (HTMLParser::getNode): 702 (HTMLParser::allowNestedRedundantTag): 703 (HTMLParser::processCloseTag): 704 (HTMLParser::isHeaderTag): 705 (HTMLParser::popNestedHeaderTag): 706 (HTMLParser::isInline): 707 (HTMLParser::isResidualStyleTag): 708 (HTMLParser::isAffectedByResidualStyle): 709 (HTMLParser::handleResidualStyleCloseTagAcrossBlocks): 710 (HTMLParser::reopenResidualStyleTags): 711 (HTMLParser::pushBlock): 712 (HTMLParser::popBlock): 713 (HTMLParser::popOneBlock): 714 (HTMLParser::popInlineBlocks): 715 (HTMLParser::freeBlock): 716 (HTMLParser::createHead): 717 (HTMLParser::handleIsindex): 718 (HTMLParser::startBody): 719 (HTMLParser::finished): 720 * khtml/html/htmlparser.h: 721 (HTMLParser::skipMode): 722 (HTMLParser::setSkipMode): 723 (HTMLParser::popBlock): 724 * khtml/html/htmltokenizer.cpp: 725 (khtml::HTMLTokenizer::HTMLTokenizer): 726 (khtml::HTMLTokenizer::parseSpecial): 727 (khtml::HTMLTokenizer::scriptHandler): 728 (khtml::HTMLTokenizer::parseComment): 729 (khtml::HTMLTokenizer::parseTag): 730 (khtml::HTMLTokenizer::processToken): 731 * khtml/html/htmltokenizer.h: 732 (khtml::Token::Token): 733 (khtml::Token::~Token): 734 (khtml::Token::addAttribute): 735 (khtml::Token::isOpenTag): 736 (khtml::Token::isCloseTag): 737 (khtml::Token::reset): 738 * khtml/khtml_part.cpp: 739 (KHTMLPart::init): 740 (KHTMLPart::selectionComputedStyle): 741 * khtml/khtmlview.cpp: 742 (KHTMLView::layout): 743 (isSubmitImage): 744 * khtml/misc/decoder.cpp: 745 (Decoder::decode): 746 * khtml/misc/hashmap.h: 747 (khtml::::size): 748 (khtml::::isEmpty): 749 (khtml::::begin): 750 (khtml::::end): 751 (khtml::::get): 752 * khtml/misc/hashset.h: 753 (khtml::::size): 754 (khtml::::isEmpty): 755 (khtml::::begin): 756 (khtml::::end): 757 (khtml::::contains): 758 * khtml/misc/hashtable.h: 759 (khtml::HashTableIterator::skipEmptyBuckets): 760 (khtml::::lookup): 761 (khtml::::find): 762 (khtml::::contains): 763 (khtml::::remove): 764 * khtml/misc/htmlhashes.cpp: 765 (khtml::getAttrID): 766 * khtml/misc/htmlhashes.h: 767 * khtml/rendering/bidi.cpp: 768 (khtml::BidiIterator::direction): 769 * khtml/rendering/break_lines.cpp: 770 (khtml::isBreakable): 771 * khtml/rendering/render_applet.cpp: 772 (RenderApplet::createWidgetIfNecessary): 773 * khtml/rendering/render_block.cpp: 774 (khtml::RenderBlock::layoutBlock): 775 * khtml/rendering/render_box.cpp: 776 (RenderBox::paintRootBoxDecorations): 777 (RenderBox::paintBackgroundExtended): 778 * khtml/rendering/render_canvasimage.cpp: 779 (RenderCanvasImage::paint): 780 * khtml/rendering/render_canvasimage.h: 781 * khtml/rendering/render_container.cpp: 782 (RenderContainer::updatePseudoChild): 783 * khtml/rendering/render_flow.cpp: 784 (RenderFlow::addFocusRingRects): 785 * khtml/rendering/render_form.cpp: 786 (RenderFieldset::findLegend): 787 (RenderSelect::updateFromElement): 788 (RenderSelect::layout): 789 (RenderSelect::slotSelected): 790 (RenderSelect::slotSelectionChanged): 791 (RenderSelect::updateSelection): 792 * khtml/rendering/render_frames.cpp: 793 (RenderPartObject::updateWidget): 794 (RenderPartObject::slotViewCleared): 795 * khtml/rendering/render_image.cpp: 796 (RenderImage::paint): 797 (RenderImage::imageMap): 798 (RenderImage::updateAltText): 799 * khtml/rendering/render_image.h: 800 * khtml/rendering/render_layer.cpp: 801 (Marquee::marqueeSpeed): 802 * khtml/rendering/render_line.cpp: 803 * khtml/rendering/render_list.cpp: 804 (getParentOfFirstLineBox): 805 * khtml/rendering/render_object.cpp: 806 (RenderObject::isBody): 807 (RenderObject::isHR): 808 (RenderObject::isHTMLMarquee): 809 (RenderObject::sizesToMaxWidth): 810 (RenderObject::information): 811 (RenderObject::setStyle): 812 (RenderObject::getTextDecorationColors): 813 (RenderObject::setPixmap): 814 * khtml/rendering/render_style.cpp: 815 (RenderStyle::getPseudoStyle): 816 * khtml/rendering/render_style.h: 817 * khtml/rendering/render_table.cpp: 818 (RenderTable::addChild): 819 (RenderTable::layout): 820 (RenderTableSection::addChild): 821 (RenderTableRow::addChild): 822 (RenderTableCell::updateFromElement): 823 (RenderTableCol::updateFromElement): 824 * khtml/xml/dom2_rangeimpl.cpp: 825 * khtml/xml/dom2_traversalimpl.cpp: 826 * khtml/xml/dom_atomicstring.cpp: 827 (DOM::equal): 828 (DOM::AtomicString::init): 829 * khtml/xml/dom_atomicstring.h: 830 * khtml/xml/dom_docimpl.cpp: 831 (DocumentImpl::createElement): 832 (DocumentImpl::importNode): 833 (DocumentImpl::createElementNS): 834 (DocumentImpl::body): 835 (DocumentImpl::shouldScheduleLayout): 836 (DocumentImpl::attrId): 837 (DocumentImpl::recalcStyleSelector): 838 * khtml/xml/dom_docimpl.h: 839 * khtml/xml/dom_elementimpl.cpp: 840 (AttrImpl::prefix): 841 (AttrImpl::setPrefix): 842 (ElementImpl::ElementImpl): 843 (ElementImpl::~ElementImpl): 844 (ElementImpl::cloneNode): 845 (ElementImpl::hasAttributes): 846 (ElementImpl::nodeName): 847 (ElementImpl::setPrefix): 848 (ElementImpl::openTagStartToString): 849 (ElementImpl::toString): 850 (StyledElementImpl::StyledElementImpl): 851 * khtml/xml/dom_elementimpl.h: 852 (DOM::ElementImpl::tagName): 853 (DOM::ElementImpl::hasTagName): 854 (DOM::ElementImpl::hasLocalName): 855 (DOM::ElementImpl::localName): 856 (DOM::ElementImpl::prefix): 857 (DOM::ElementImpl::namespaceURI): 858 (DOM::ElementImpl::mouseEventHandler): 859 * khtml/xml/dom_nodeimpl.cpp: 860 (DOM::NodeImpl::lastDescendant): 861 (DOM::NodeImpl::prefix): 862 (DOM::NodeImpl::setPrefix): 863 (DOM::NodeImpl::localName): 864 (DOM::NodeImpl::namespaceURI): 865 (DOM::NodeImpl::checkSetPrefix): 866 (DOM::NodeImpl::isAtomicNode): 867 (DOM::NodeImpl::maxDeepOffset): 868 (DOM::NodeImpl::enclosingBlockFlowOrTableElement): 869 (DOM::NodeImpl::enclosingBlockFlowElement): 870 (DOM::NodeImpl::enclosingInlineElement): 871 (DOM::NodeImpl::rootEditableElement): 872 (DOM::NodeImpl::getElementsByTagNameNS): 873 (DOM::NodeImpl::showTreeAndMark): 874 (DOM::ContainerNodeImpl::addChild): 875 (DOM::TagNodeListImpl::TagNodeListImpl): 876 (DOM::TagNodeListImpl::item): 877 (DOM::TagNodeListImpl::nodeMatches): 878 * khtml/xml/dom_nodeimpl.h: 879 (DOM::NodeImpl::hasTagName): 880 (DOM::NodeImpl::isCommentNode): 881 (DOM::NodeImpl::isDocumentNode): 882 (DOM::NodeImpl::closeRenderer): 883 (DOM::NodeImpl::getElementsByTagName): 884 * khtml/xml/dom_position.cpp: 885 (DOM::Position::downstream): 886 (DOM::Position::rendersInDifferentPosition): 887 (DOM::Position::leadingWhitespacePosition): 888 (DOM::Position::trailingWhitespacePosition): 889 * khtml/xml/dom_qname.cpp: 890 (DOM::hashComponents): 891 (DOM::QNameHash::hash): 892 (DOM::QNameHash::equal): 893 (DOM::equalComponents): 894 (DOM::convertComponents): 895 (DOM::QualifiedName::QualifiedName): 896 (DOM::QualifiedName::deref): 897 (DOM::QualifiedName::setPrefix): 898 * khtml/xml/dom_qname.h: 899 (DOM::QualifiedName::hasPrefix): 900 (DOM::operator==): 901 * khtml/xml/dom_textimpl.cpp: 902 (CommentImpl::localName): 903 (CommentImpl::nodeName): 904 (TextImpl::localName): 905 (TextImpl::nodeName): 906 * khtml/xml/dom_textimpl.h: 907 (DOM::CommentImpl::isCommentNode): 908 (DOM::TextImpl::isTextNode): 909 * khtml/xml/xml_tokenizer.cpp: 910 (khtml::XMLTokenizer::startElement): 911 (khtml::XMLTokenizer::insertErrorMessageBlock): 912 (khtml::XMLTokenizer::addScripts): 913 * kwq/DOM.mm: 914 (-[DOMNode setPrefix:]): 915 (+[DOMNode _nodeWithImpl:]): 916 (-[DOMElement tagName]): 917 * kwq/DOMHTML.mm: 918 (-[DOMHTMLQuoteElement _quoteElementImpl]): 919 * kwq/KWQAccObject.mm: 920 (-[KWQAccObject role]): 921 (-[KWQAccObject title]): 922 (-[KWQAccObject accessibilityIsIgnored]): 923 * kwq/KWQDOMNode.cpp: Removed. 924 * kwq/KWQDOMNode.h: Removed. 925 * kwq/KWQFont.h: 926 (QFont::): 927 (QFont::isFixedPitch): 928 * kwq/KWQFont.mm: 929 (QFont::QFont): 930 (QFont::operator=): 931 (QFont::determinePitch): 932 (QFont::operator==): 933 * kwq/KWQKHTMLPart.cpp: 934 (KWQKHTMLPart::isFrameSet): 935 * kwq/KWQKHTMLPart.mm: 936 (scanForForm): 937 (KWQKHTMLPart::currentForm): 938 (KWQKHTMLPart::searchForLabelsAboveCell): 939 (KWQKHTMLPart::searchForLabelsBeforeElement): 940 (listParent): 941 (isTextFirstInListItem): 942 (KWQKHTMLPart::attributedString): 943 (KWQKHTMLPart::styleForSelectionStart): 944 (KWQKHTMLPart::setSelectionFromNone): 945 * kwq/KWQRenderTreeDebug.cpp: 946 (getTagName): 947 * kwq/WebCoreBridge.mm: 948 (inputElementFromDOMElement): 949 (formElementFromDOMElement): 950 (-[WebCoreBridge elementAtPoint:]): 951 * layout-tests/fast/dom/css-dom-read-expected.txt: 952 * layout-tests/fast/overflow/003-expected.txt: 953 * layout-tests/fast/tokenizer/002-expected.txt: 954 * layout-tests/fast/tokenizer/external-script-document-write-expected.txt: 955 * layout-tests/fast/tokenizer/script_extra_close-expected.txt: 956 * layout-tests/fast/tokenizer/script_quirk-expected.txt: Removed. 957 * layout-tests/fast/tokenizer/script_quirk.html: Removed. 958 1 959 2005-07-08 Eric Seidel <eseidel@apple.com> 2 960 -
trunk/WebCore/WebCore.pbproj/project.pbxproj
r9636 r9639 221 221 //2D3 222 222 //2D4 223 //350224 //351225 //352226 //353227 //354228 354F248902EE28590ACA2ACA = {229 fileEncoding = 30;230 isa = PBXFileReference;231 lastKnownFileType = sourcecode.c.h;232 path = KWQDOMNode.h;233 refType = 4;234 sourceTree = "<group>";235 };236 354F248A02EE28590ACA2ACA = {237 fileEncoding = 30;238 isa = PBXFileReference;239 lastKnownFileType = sourcecode.cpp.cpp;240 path = KWQDOMNode.cpp;241 refType = 4;242 sourceTree = "<group>";243 };244 //350245 //351246 //352247 //353248 //354249 223 //510 250 224 //511 … … 2492 2466 93F198DE08245E59001E9ABC, 2493 2467 93F198E008245E59001E9ABC, 2494 93F198E208245E59001E9ABC,2495 2468 93F198E308245E59001E9ABC, 2496 2469 93F198E408245E59001E9ABC, … … 2569 2542 93F1992F08245E59001E9ABC, 2570 2543 93F1993008245E59001E9ABC, 2571 93F1993108245E59001E9ABC,2572 2544 93F1993208245E59001E9ABC, 2573 2545 93F1993308245E59001E9ABC, … … 2724 2696 93F199CA08245E59001E9ABC, 2725 2697 93F199CB08245E59001E9ABC, 2726 93F199CC08245E59001E9ABC,2727 2698 93F199CE08245E59001E9ABC, 2728 2699 93F199CF08245E59001E9ABC, … … 2805 2776 65DE852908765FC30011428A, 2806 2777 65DE852A08765FC30011428A, 2778 A85D7C19087A6ED9006A9172, 2779 BCEF3435087B563E00BBF833, 2807 2780 A8FD8B87087CB45700DC3707, 2808 2781 ); … … 3050 3023 }; 3051 3024 }; 3052 93F198E208245E59001E9ABC = {3053 fileRef = F523D23602DE4396018635CA;3054 isa = PBXBuildFile;3055 settings = {3056 };3057 };3058 3025 93F198E308245E59001E9ABC = { 3059 3026 fileRef = F523D23802DE4396018635CA; … … 3508 3475 93F1993008245E59001E9ABC = { 3509 3476 fileRef = F58785EA02DE37CB01EA4122; 3510 isa = PBXBuildFile;3511 settings = {3512 };3513 };3514 93F1993108245E59001E9ABC = {3515 fileRef = 354F248902EE28590ACA2ACA;3516 3477 isa = PBXBuildFile; 3517 3478 settings = { … … 4476 4437 93F199CB08245E59001E9ABC = { 4477 4438 fileRef = BCBDB094059A28B100B83B92; 4478 isa = PBXBuildFile;4479 settings = {4480 };4481 };4482 93F199CC08245E59001E9ABC = {4483 fileRef = BC7FDE3205C1D9AB0070A902;4484 4439 isa = PBXBuildFile; 4485 4440 settings = { … … 5020 4975 93F19A8C08245E59001E9ABC, 5021 4976 93F19A8D08245E59001E9ABC, 5022 93F19A8E08245E59001E9ABC,5023 4977 93F19A8F08245E59001E9ABC, 5024 4978 93F19A9008245E59001E9ABC, … … 5073 5027 93F19AC108245E59001E9ABC, 5074 5028 93F19AC208245E59001E9ABC, 5075 93F19AC308245E59001E9ABC,5076 5029 93F19AC408245E59001E9ABC, 5077 5030 93F19AC508245E59001E9ABC, … … 5115 5068 93F19AED08245E59001E9ABC, 5116 5069 93F19AEE08245E59001E9ABC, 5117 93F19AEF08245E59001E9ABC,5118 5070 93F19AF008245E59001E9ABC, 5119 5071 93F19AF108245E59001E9ABC, … … 5180 5132 550A0BCD085F604D007353D6, 5181 5133 65F3782A0870D958000B2F94, 5134 A85D7C18087A6ED9006A9172, 5135 BCEF3434087B563E00BBF833, 5182 5136 A8FD8B86087CB44C00DC3707, 5183 5137 ); … … 5821 5775 }; 5822 5776 }; 5823 93F19A8E08245E59001E9ABC = {5824 fileRef = F523D23502DE4396018635CA;5825 isa = PBXBuildFile;5826 settings = {5827 };5828 };5829 5777 93F19A8F08245E59001E9ABC = { 5830 5778 fileRef = F523D23702DE4396018635CA; … … 6139 6087 }; 6140 6088 }; 6141 93F19AC308245E59001E9ABC = {6142 fileRef = 354F248A02EE28590ACA2ACA;6143 isa = PBXBuildFile;6144 settings = {6145 };6146 };6147 6089 93F19AC408245E59001E9ABC = { 6148 6090 fileRef = F5117BCA02F9FFEF018635CE; … … 6387 6329 93F19AEE08245E59001E9ABC = { 6388 6330 fileRef = BCBDB093059A28B100B83B92; 6389 isa = PBXBuildFile;6390 settings = {6391 };6392 };6393 93F19AEF08245E59001E9ABC = {6394 fileRef = BC7FDE3105C1D9AB0070A902;6395 6331 isa = PBXBuildFile; 6396 6332 settings = { … … 30439 30375 sourceTree = "<group>"; 30440 30376 }; 30441 BC7FDE3105C1D9AB0070A902 = {30442 fileEncoding = 30;30443 isa = PBXFileReference;30444 lastKnownFileType = sourcecode.cpp.cpp;30445 path = xml_namespace_table.cpp;30446 refType = 4;30447 sourceTree = "<group>";30448 };30449 BC7FDE3205C1D9AB0070A902 = {30450 fileEncoding = 30;30451 isa = PBXFileReference;30452 lastKnownFileType = sourcecode.c.h;30453 path = xml_namespace_table.h;30454 refType = 4;30455 sourceTree = "<group>";30456 };30457 30377 BC80A6930468B78100DBCC9C = { 30458 30378 fileEncoding = 30; … … 30599 30519 refType = 4; 30600 30520 sourceTree = "<group>"; 30521 }; 30522 BCEF3432087B563E00BBF833 = { 30523 fileEncoding = 30; 30524 isa = PBXFileReference; 30525 lastKnownFileType = sourcecode.cpp.cpp; 30526 path = htmlfactory.cpp; 30527 refType = 4; 30528 sourceTree = "<group>"; 30529 }; 30530 BCEF3433087B563E00BBF833 = { 30531 fileEncoding = 30; 30532 isa = PBXFileReference; 30533 lastKnownFileType = sourcecode.c.h; 30534 path = htmlfactory.h; 30535 refType = 4; 30536 sourceTree = "<group>"; 30537 }; 30538 BCEF3434087B563E00BBF833 = { 30539 fileRef = BCEF3432087B563E00BBF833; 30540 isa = PBXBuildFile; 30541 settings = { 30542 }; 30543 }; 30544 BCEF3435087B563E00BBF833 = { 30545 fileRef = BCEF3433087B563E00BBF833; 30546 isa = PBXBuildFile; 30547 settings = { 30548 }; 30601 30549 }; 30602 30550 BCF0192403D3802200B2D04D = { … … 31015 30963 F58784CD02DE375901EA4122, 31016 30964 F58784DA02DE375901EA4122, 31017 354F248902EE28590ACA2ACA,31018 354F248A02EE28590ACA2ACA,31019 30965 931C8A160380288B008635CE, 31020 30966 931C8A170380288B008635CE, … … 31985 31931 sourceTree = "<group>"; 31986 31932 }; 31987 F523D23502DE4396018635CA = {31988 fileEncoding = 30;31989 isa = PBXFileReference;31990 lastKnownFileType = sourcecode.cpp.cpp;31991 path = dtd.cpp;31992 refType = 4;31993 sourceTree = "<group>";31994 };31995 F523D23602DE4396018635CA = {31996 fileEncoding = 30;31997 isa = PBXFileReference;31998 lastKnownFileType = sourcecode.c.h;31999 path = dtd.h;32000 refType = 4;32001 sourceTree = "<group>";32002 };32003 31933 F523D23702DE4396018635CA = { 32004 31934 fileEncoding = 30; … … 32227 32157 F523D27702DE4398018635CA = { 32228 32158 children = ( 32159 BCEF3432087B563E00BBF833, 32160 BCEF3433087B563E00BBF833, 32229 32161 550A0BCB085F604D007353D6, 32230 32162 550A0BCC085F604D007353D6, 32231 F523D23502DE4396018635CA,32232 F523D23602DE4396018635CA,32233 32163 F523D23702DE4396018635CA, 32234 32164 F523D23802DE4396018635CA, … … 32942 32872 F523D30702DE4476018635CA, 32943 32873 F523D30802DE4476018635CA, 32944 BC7FDE3105C1D9AB0070A902,32945 BC7FDE3205C1D9AB0070A902,32946 32874 F523D30902DE4476018635CA, 32947 32875 F523D30A02DE4476018635CA, -
trunk/WebCore/khtml/css/css_base.cpp
r9361 r9639 94 94 // -------------------------------------------------------------------------------- 95 95 96 const QualifiedName& CSSSelector::anyTagName() 97 { 98 static QualifiedName anyName(nullAtom, starAtom, starAtom); 99 return anyName; 100 } 101 96 102 void CSSSelector::print(void) 97 103 { 98 kdDebug( 6080 ) << "[Selector: tag = " << tag << ", attr = \"" << attr << "\", match = \"" << match104 kdDebug( 6080 ) << "[Selector: tag = " << tag.localName().string() << ", attr = \"" << attr << "\", match = \"" << match 99 105 << "\" value = \"" << value.string().latin1() << "\" relation = " << (int)relation 100 106 << "]" << endl; … … 108 114 // FIXME: Pseudo-elements and pseudo-classes do not have the same specificity. This function 109 115 // isn't quite correct. 110 int s = ( (localNamePart(tag) == anyLocalName)? 0 : 1);116 int s = (tag.localName() == starAtom ? 0 : 1); 111 117 switch(match) 112 118 { … … 241 247 DOMString CSSSelector::selectorText() const 242 248 { 243 // FIXME: Support namespaces when dumping the selector text. This requires preserving 244 // the original namespace prefix used. Ugh. -dwh 249 // FIXME: Support namespaces when dumping the selector text. -dwh 245 250 DOMString str; 246 251 const CSSSelector* cs = this; 247 Q_UINT16 tag = localNamePart(cs->tag);248 if ( tag == anyLocalName && cs->attr == ATTR_ID && cs->match == CSSSelector::Exact)252 const AtomicString& localName = cs->tag.localName(); 253 if (localName == starAtom && cs->attr == ATTR_ID && cs->match == CSSSelector::Exact) 249 254 { 250 255 str = "#"; 251 256 str += cs->value.string(); 252 257 } 253 else if ( tag == anyLocalName && cs->attr == ATTR_CLASS && cs->match == CSSSelector::Class)258 else if (localName == starAtom && cs->attr == ATTR_CLASS && cs->match == CSSSelector::Class) 254 259 { 255 260 str = "."; 256 261 str += cs->value.string(); 257 262 } 258 else if ( tag == anyLocalName && cs->match == CSSSelector::PseudoClass)263 else if (localName == starAtom && cs->match == CSSSelector::PseudoClass) 259 264 { 260 265 str = ":"; 261 266 str += cs->value.string(); 262 267 } 263 else if ( tag == anyLocalName && cs->match == CSSSelector::PseudoElement)268 else if (localName == starAtom && cs->match == CSSSelector::PseudoElement) 264 269 { 265 270 str = "::"; … … 268 273 else 269 274 { 270 if ( tag == anyLocalName)275 if (localName == starAtom) 271 276 str = "*"; 272 277 else 273 str = getTagName( cs->tag );274 if ( cs->attr == ATTR_ID && cs->match == CSSSelector::Exact)278 str = localName; 279 if (cs->attr == ATTR_ID && cs->match == CSSSelector::Exact) 275 280 { 276 281 str += "#"; 277 282 str += cs->value.string(); 278 283 } 279 else if ( cs->attr == ATTR_CLASS && cs->match == CSSSelector::Class)284 else if (cs->attr == ATTR_CLASS && cs->match == CSSSelector::Class) 280 285 { 281 286 str += "."; 282 287 str += cs->value.string(); 283 288 } 284 else if ( cs->match == CSSSelector::PseudoClass)289 else if (cs->match == CSSSelector::PseudoClass) 285 290 { 286 291 str += ":"; 287 292 str += cs->value.string(); 288 293 } 289 else if ( cs->match == CSSSelector::PseudoElement)294 else if (cs->match == CSSSelector::PseudoElement) 290 295 { 291 296 str += "::"; … … 293 298 } 294 299 // optional attribute 295 if ( cs->attr) {296 DOMString attrName = getAttrName( cs->attr);300 if (cs->attr) { 301 DOMString attrName = getAttrName(cs->attr); 297 302 str += "["; 298 303 str += attrName; -
trunk/WebCore/khtml/css/css_base.h
r9361 r9639 28 28 #include "dom/dom_misc.h" 29 29 #include "xml/dom_nodeimpl.h" 30 #include "dom_qname.h" 30 31 #include "misc/shared.h" 31 32 #include <qdatetime.h> … … 47 48 48 49 struct CSSNamespace { 49 DOMString m_prefix;50 DOMString m_uri;50 AtomicString m_prefix; 51 AtomicString m_uri; 51 52 CSSNamespace* m_parent; 52 53 53 54 MAIN_THREAD_ALLOCATED; 54 55 55 CSSNamespace(const DOMString& p, const DOMString& u, CSSNamespace* parent)56 CSSNamespace(const AtomicString& p, const AtomicString& u, CSSNamespace* parent) 56 57 :m_prefix(p), m_uri(u), m_parent(parent) {} 57 58 ~CSSNamespace() { delete m_parent; } 58 59 59 const DOMString& uri() { return m_uri; }60 const DOMString& prefix() { return m_prefix; }60 const AtomicString& uri() { return m_uri; } 61 const AtomicString& prefix() { return m_prefix; } 61 62 62 CSSNamespace* namespaceForPrefix(const DOMString& prefix) {63 CSSNamespace* namespaceForPrefix(const AtomicString& prefix) { 63 64 if (prefix == m_prefix) 64 65 return this; … … 73 74 { 74 75 public: 75 CSSSelector() 76 : tagHistory(0), simpleSelector(0), nextSelector(0), attr(0), tag(anyQName), 76 CSSSelector() 77 : tagHistory(0), simpleSelector(0), nextSelector(0), attr(0), tag(anyTagName()), 78 relation( Descendant ), match( None ), 79 pseudoId( 0 ), _pseudoType(PseudoNotParsed) 80 {} 81 82 CSSSelector(const QualifiedName& qName) 83 : tagHistory(0), simpleSelector(0), nextSelector(0), attr(0), tag(qName), 77 84 relation( Descendant ), match( None ), 78 85 pseudoId( 0 ), _pseudoType(PseudoNotParsed) … … 168 175 } 169 176 177 static const QualifiedName& anyTagName(); 178 179 bool hasTag() const { return tag != anyTagName(); } 180 170 181 mutable DOM::AtomicString value; 171 182 CSSSelector* tagHistory; … … 173 184 CSSSelector* nextSelector; // used for ,-chained selectors 174 185 Q_UINT32 attr; 175 Q_UINT32 tag; 186 187 QualifiedName tag; 176 188 177 189 Relation relation : 3; -
trunk/WebCore/khtml/css/css_ruleimpl.cpp
r9158 r9639 32 32 33 33 #include "misc/loader.h" 34 #include "misc/htmltags.h"35 34 #include "misc/htmlattrs.h" 36 35 #include "xml/dom_docimpl.h" -
trunk/WebCore/khtml/css/css_ruleimpl.h
r9151 r9639 31 31 #include "misc/loader_client.h" 32 32 #include "misc/shared.h" 33 #include "misc/main_thread_malloc.h" 33 34 #include "css_valueimpl.h" 34 35 … … 51 52 : StyleBaseImpl(parent), m_type(CSSRule::UNKNOWN_RULE) {} 52 53 54 MAIN_THREAD_ALLOCATED; 55 53 56 virtual bool isRule() { return true; } 54 57 unsigned short type() const { return m_type; } … … 72 75 : CSSRuleImpl(parent) { m_type = CSSRule::CHARSET_RULE; } 73 76 77 MAIN_THREAD_ALLOCATED; 78 74 79 virtual bool isCharsetRule() { return true; } 75 80 … … 86 91 public: 87 92 CSSFontFaceRuleImpl(StyleBaseImpl *parent); 88 89 93 virtual ~CSSFontFaceRuleImpl(); 90 94 95 MAIN_THREAD_ALLOCATED; 96 91 97 CSSMutableStyleDeclarationImpl *style() const { return m_style; } 92 98 … … 105 111 CSSImportRuleImpl( StyleBaseImpl *parent, const DOM::DOMString &href, 106 112 MediaListImpl *media ); 107 108 113 virtual ~CSSImportRuleImpl(); 114 115 MAIN_THREAD_ALLOCATED; 109 116 110 117 DOM::DOMString href() const { return m_strHref; } … … 157 164 CSSMediaRuleImpl( StyleBaseImpl *parent, const DOM::DOMString &media ); 158 165 CSSMediaRuleImpl( StyleBaseImpl *parent, MediaListImpl *mediaList, CSSRuleListImpl *ruleList ); 159 160 166 virtual ~CSSMediaRuleImpl(); 167 168 MAIN_THREAD_ALLOCATED; 161 169 162 170 MediaListImpl *media() const { return m_lstMedia; } … … 180 188 public: 181 189 CSSPageRuleImpl(StyleBaseImpl *parent); 182 183 190 virtual ~CSSPageRuleImpl(); 191 192 MAIN_THREAD_ALLOCATED; 184 193 185 194 CSSMutableStyleDeclarationImpl *style() const { return m_style; } … … 200 209 public: 201 210 CSSStyleRuleImpl(StyleBaseImpl *parent); 202 203 211 virtual ~CSSStyleRuleImpl(); 212 213 MAIN_THREAD_ALLOCATED; 204 214 205 215 CSSMutableStyleDeclarationImpl *style() const { return m_style; } … … 228 238 CSSUnknownRuleImpl(StyleBaseImpl *parent) : CSSRuleImpl(parent) {} 229 239 240 MAIN_THREAD_ALLOCATED; 241 230 242 virtual bool isUnknownRule() { return true; } 231 243 }; -
trunk/WebCore/khtml/css/css_stylesheetimpl.cpp
r9156 r9639 39 39 #include "misc/loader.h" 40 40 41 #include "xml_namespace_table.h"42 43 41 #include <kdebug.h> 44 42 … … 211 209 } 212 210 213 void CSSStyleSheetImpl::addNamespace(CSSParser* p, const DOM::DOMString& prefix, const DOM::DOMString& uri)211 void CSSStyleSheetImpl::addNamespace(CSSParser* p, const AtomicString& prefix, const AtomicString& uri) 214 212 { 215 213 if (uri.isEmpty()) … … 221 219 // Set the default namespace on the parser so that selectors that omit namespace info will 222 220 // be able to pick it up easily. 223 p->defaultNamespace = XmlNamespaceTable::getNamespaceID(uri, false); 224 } 225 226 void CSSStyleSheetImpl::determineNamespace(Q_UINT32& id, const DOM::DOMString& prefix) 227 { 228 // If the stylesheet has no namespaces we can just return. There won't be any need to ever check 229 // namespace values in selectors. 230 if (!m_namespaces) 231 return; 232 221 p->defaultNamespace = uri; 222 } 223 224 const AtomicString& CSSStyleSheetImpl::determineNamespace(const AtomicString& prefix) 225 { 233 226 if (prefix.isEmpty()) 234 id = makeId(noNamespace, localNamePart(id)); // No namespace. If an element/attribute has a namespace, we won't match it.235 else if (prefix == "*")236 id = makeId(anyNamespace, localNamePart(id)); // We'll match any namespace.237 else {227 return emptyAtom; // No namespace. If an element/attribute has a namespace, we won't match it. 228 else if (prefix == starAtom) 229 return starAtom; // We'll match any namespace. 230 else if (m_namespaces) { 238 231 CSSNamespace* ns = m_namespaces->namespaceForPrefix(prefix); 239 232 if (ns) 240 // Look up the id for this namespace URI.241 id = makeId(XmlNamespaceTable::getNamespaceID(ns->uri(), false), localNamePart(id));242 }233 return ns->uri(); 234 } 235 return emptyAtom; // Assume we wont match any namespaces. 243 236 } 244 237 -
trunk/WebCore/khtml/css/css_stylesheetimpl.h
r9156 r9639 105 105 unsigned long addRule ( const DOMString &selector, const DOMString &style, long index, int &exceptioncode ); 106 106 107 void addNamespace(CSSParser* p, const DOM::DOMString& prefix, const DOM::DOMString& uri);108 void determineNamespace(Q_UINT32& id, const DOM::DOMString& prefix);107 void addNamespace(CSSParser* p, const AtomicString& prefix, const AtomicString& uri); 108 const AtomicString& determineNamespace(const AtomicString& prefix); 109 109 110 110 virtual bool parseString( const DOMString &string, bool strict = true ); -
trunk/WebCore/khtml/css/cssparser.cpp
r9157 r9639 103 103 inParseShortHand = false; 104 104 105 defaultNamespace = anyNamespace;105 defaultNamespace = starAtom; 106 106 107 107 yy_start = 1; … … 162 162 { 163 163 styleElement = sheet; 164 defaultNamespace = anyNamespace; // Reset the default namespace.164 defaultNamespace = starAtom; // Reset the default namespace. 165 165 166 166 setupParser ("", string, ""); -
trunk/WebCore/khtml/css/cssparser.h
r8041 r9639 165 165 bool inParseShortHand; 166 166 167 Q_UINT16defaultNamespace;167 AtomicString defaultNamespace; 168 168 169 169 static CSSParser *currentParser; -
trunk/WebCore/khtml/css/cssstyleselector.cpp
r9597 r9639 340 340 firstRuleIndex, lastRuleIndex); 341 341 } 342 matchRulesForList(rules->getTagRules( localNamePart(element->id())),342 matchRulesForList(rules->getTagRules(element->localName().implementation()), 343 343 firstRuleIndex, lastRuleIndex); 344 344 matchRulesForList(rules->getUniversalRules(), firstRuleIndex, lastRuleIndex); … … 361 361 for (CSSRuleData* d = rules->first(); d; d = d->next()) { 362 362 CSSStyleRuleImpl* rule = d->rule(); 363 Q_UINT16 cssTagId = localNamePart(element->id());364 Q_UINT16 tag = localNamePart(d->selector()->tag);365 if (( cssTagId == tag || tag == anyLocalName) && checkSelector(d->selector(), element)) {363 const AtomicString& localName = element->localName(); 364 const AtomicString& selectorLocalName = d->selector()->tag.localName(); 365 if ((localName == selectorLocalName || selectorLocalName == starAtom) && checkSelector(d->selector(), element)) { 366 366 // If the rule has no properties to apply, then ignore it. 367 367 CSSMutableStyleDeclarationImpl* decl = rule->declaration(); … … 610 610 bool mouseInside = element->renderer() ? element->renderer()->mouseInside() : false; 611 611 StyledElementImpl* s = static_cast<StyledElementImpl*>(n); 612 if (s->renderer() && (s-> id() == element->id()) && !s->hasID() &&612 if (s->renderer() && (s->tagName() == element->tagName()) && !s->hasID() && 613 613 (s->hasClass() == element->hasClass()) && !s->inlineStyleDecl() && 614 614 (s->hasMappedAttributes() == styledElement->hasMappedAttributes()) && … … 886 886 // these tags to retain their display types. 887 887 if (!strictParsing && e) { 888 if (e-> id() == ID_TD) {888 if (e->hasTagName(HTMLNames::td())) { 889 889 style->setDisplay(TABLE_CELL); 890 890 style->setFloating(FNONE); 891 891 } 892 else if (e-> id() == ID_TABLE)892 else if (e->hasTagName(HTMLNames::table())) 893 893 style->setDisplay(style->isDisplayInlineType() ? INLINE_TABLE : TABLE); 894 894 } … … 896 896 // Frames and framesets never honor position:relative or position:absolute. This is necessary to 897 897 // fix a crash where a site tries to position these objects. They also never honor display. 898 if (e && (e-> id() == ID_FRAME || e->id() == ID_FRAMESET)) {898 if (e && (e->hasTagName(HTMLNames::frame()) || e->hasTagName(HTMLNames::frameset()))) { 899 899 style->setPosition(STATIC); 900 900 style->setDisplay(BLOCK); … … 902 902 903 903 // Table headers with a text-align of auto will change the text-align to center. 904 if (e && e-> id() == ID_TH&& style->textAlign() == TAAUTO)904 if (e && e->hasTagName(HTMLNames::th()) && style->textAlign() == TAAUTO) 905 905 style->setTextAlign(CENTER); 906 906 … … 980 980 // so, we can't allow that to apply to every element on the page. We assume the author intended 981 981 // to apply the rules only to links. 982 bool onlyHoverActive = ( sel->tag == anyQName&&982 bool onlyHoverActive = (!sel->hasTag() && 983 983 (sel->match == CSSSelector::PseudoClass && 984 984 (sel->pseudoType() == CSSSelector::PseudoHover || … … 1097 1097 return false; 1098 1098 1099 if (sel->tag != anyQName) { 1100 int eltID = e->id(); 1101 Q_UINT16 localName = localNamePart(eltID); 1102 Q_UINT16 ns = namespacePart(eltID); 1103 Q_UINT16 selLocalName = localNamePart(sel->tag); 1104 Q_UINT16 selNS = namespacePart(sel->tag); 1105 1106 if (localName <= ID_LAST_TAG && e->isHTMLElement()) 1107 ns = xhtmlNamespace; // FIXME: Really want to move away from this complicated hackery and just 1108 // switch tags and attr names over to AtomicStrings. 1109 1110 if ((selLocalName != anyLocalName && localName != selLocalName) || 1111 (selNS != anyNamespace && ns != selNS)) 1099 if (sel->hasTag()) { 1100 const AtomicString& localName = e->localName(); 1101 const AtomicString& ns = e->namespaceURI(); 1102 const AtomicString& selLocalName = sel->tag.localName(); 1103 const AtomicString& selNS = sel->tag.namespaceURI(); 1104 1105 if ((selLocalName != starAtom && localName != selLocalName) || 1106 (selNS != starAtom && ns != selNS)) 1112 1107 return false; 1113 1108 } … … 1296 1291 // If we're in quirks mode, then hover should never match anchors with no 1297 1292 // href. This is important for sites like wsj.com. 1298 if (strictParsing || e->id() != ID_A|| e->isLink()) {1293 if (strictParsing || !e->hasTagName(HTMLNames::a()) || e->isLink()) { 1299 1294 if (element == e && style) 1300 1295 style->setAffectedByHoverRules(true); … … 1327 1322 // If we're in quirks mode, then :active should never match anchors with no 1328 1323 // href. 1329 if (strictParsing || e->id() != ID_A|| e->isLink()) {1324 if (strictParsing || !e->hasTagName(HTMLNames::a()) || e->isLink()) { 1330 1325 if (element == e && style) 1331 1326 style->setAffectedByActiveRules(true); … … 1421 1416 } 1422 1417 1423 void CSSRuleSet::addToRuleSet(int key, IntRuleMap& map,1424 CSSStyleRuleImpl* rule, CSSSelector* sel)1425 {1426 assert(key);1427 assert(key != -1);1428 CSSRuleDataList* rules = map.get(key);1429 if (!rules) {1430 rules = new CSSRuleDataList(m_ruleCount++, rule, sel);1431 map.insert(key, rules);1432 } else1433 rules->append(m_ruleCount++, rule, sel);1434 }1435 1436 1418 void CSSRuleSet::addRule(CSSStyleRuleImpl* rule, CSSSelector* sel) 1437 1419 { … … 1445 1427 } 1446 1428 1447 Q_UINT16 localName = localNamePart(sel->tag); 1448 if (localName != anyLocalName) { 1449 // FIXME: maybe it would be better to just use an int-keyed HashMap here 1450 addToRuleSet(localName, m_tagRules, rule, sel); 1429 const AtomicString& localName = sel->tag.localName(); 1430 if (localName != starAtom) { 1431 addToRuleSet(localName.implementation(), m_tagRules, rule, sel); 1451 1432 return; 1452 1433 } -
trunk/WebCore/khtml/css/cssstyleselector.h
r9597 r9639 25 25 26 26 #include <qptrvector.h> 27 #include <qptrdict.h>28 27 #include "misc/pointerhash.h" 29 28 … … 275 274 276 275 typedef HashMap<DOM::DOMStringImpl *, CSSRuleDataList *, PointerHash<DOM::DOMStringImpl *> > AtomRuleMap; 277 typedef HashMap<int, CSSRuleDataList *, PointerHash<int> > IntRuleMap;278 276 279 277 void addRulesFromSheet(DOM::CSSStyleSheetImpl* sheet, const DOM::DOMString &medium = "screen"); … … 282 280 void addToRuleSet(DOM::DOMStringImpl* key, AtomRuleMap& map, 283 281 DOM::CSSStyleRuleImpl* rule, DOM::CSSSelector* sel); 284 void addToRuleSet(int key, IntRuleMap& map,285 DOM::CSSStyleRuleImpl* rule, DOM::CSSSelector* sel);286 282 287 283 CSSRuleDataList* getIDRules(DOM::DOMStringImpl* key) { return m_idRules.get(key); } 288 284 CSSRuleDataList* getClassRules(DOM::DOMStringImpl* key) { return m_classRules.get(key); } 289 CSSRuleDataList* getTagRules( intkey) { return m_tagRules.get(key); }285 CSSRuleDataList* getTagRules(DOM::DOMStringImpl* key) { return m_tagRules.get(key); } 290 286 CSSRuleDataList* getUniversalRules() { return m_universalRules; } 291 287 … … 293 289 AtomRuleMap m_idRules; 294 290 AtomRuleMap m_classRules; 295 IntRuleMap m_tagRules;291 AtomRuleMap m_tagRules; 296 292 CSSRuleDataList* m_universalRules; 297 293 -
trunk/WebCore/khtml/css/parser.y
r9609 r9639 35 35 #include <misc/htmlhashes.h> 36 36 #include "cssparser.h" 37 38 #include "xml_namespace_table.h" 39 37 40 38 #include <assert.h> 41 39 #include <kdebug.h> … … 131 129 int prop_id; 132 130 int attribute; 133 int element;134 131 CSSSelector::Relation relation; 135 132 bool b; … … 176 173 %token '.' 177 174 %token '[' 175 176 %token <string> '*' 178 177 179 178 %token IMPORT_SYM … … 266 265 %type <value> function 267 266 268 %type < element> element_name267 %type <string> element_name 269 268 270 269 %type <attribute> attrib_id … … 406 405 CSSParser *p = static_cast<CSSParser *>(parser); 407 406 if (p->styleElement && p->styleElement->isCSSStyleSheet()) 408 static_cast<CSSStyleSheetImpl*>(p->styleElement)->addNamespace(p, domString($3), domString($4));407 static_cast<CSSStyleSheetImpl*>(p->styleElement)->addNamespace(p, atomicString($3), atomicString($4)); 409 408 } 410 409 | NAMESPACE_SYM error invalid_block … … 625 624 simple_selector: 626 625 element_name maybe_space { 627 $$ = new CSSSelector();628 $$ ->tag = $1;626 CSSParser *p = static_cast<CSSParser *>(parser); 627 $$ = new CSSSelector(QualifiedName(nullAtom, atomicString($1), p->defaultNamespace)); 629 628 } 630 629 | element_name specifier_list maybe_space { 631 $$ = $2; 632 if ( $$ ) 633 $$->tag = $1; 630 $$ = $2; 631 if ($$) { 632 CSSParser *p = static_cast<CSSParser *>(parser); 633 $$->tag = QualifiedName(nullAtom, atomicString($1), p->defaultNamespace); 634 } 634 635 } 635 636 | specifier_list maybe_space { 636 637 $$ = $1; 637 if ($$) 638 $$->tag = makeId(static_cast<CSSParser*>(parser)->defaultNamespace, anyLocalName);; 638 CSSParser *p = static_cast<CSSParser *>(parser); 639 if ($$ && p->defaultNamespace != starAtom) 640 $$->tag = QualifiedName(nullAtom, starAtom, p->defaultNamespace); 639 641 } 640 642 | namespace_selector '|' element_name maybe_space { 641 $$ = new CSSSelector(); 642 $$->tag = $3; 643 AtomicString namespacePrefix = atomicString($1); 643 644 CSSParser *p = static_cast<CSSParser *>(parser); 644 645 if (p->styleElement && p->styleElement->isCSSStyleSheet()) 645 static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->tag, domString($1)); 646 $$ = new CSSSelector(QualifiedName(namespacePrefix, 647 atomicString($3), 648 static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(namespacePrefix))); 649 else // FIXME: Shouldn't this case be an error? 650 $$ = new CSSSelector(QualifiedName(nullAtom, atomicString($3), p->defaultNamespace)); 646 651 } 647 652 | namespace_selector '|' element_name specifier_list maybe_space { 648 653 $$ = $4; 649 654 if ($$) { 650 $$->tag = $3;655 AtomicString namespacePrefix = atomicString($1); 651 656 CSSParser *p = static_cast<CSSParser *>(parser); 652 657 if (p->styleElement && p->styleElement->isCSSStyleSheet()) 653 static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->tag, domString($1)); 658 $$->tag = QualifiedName(namespacePrefix, 659 atomicString($3), 660 static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(namespacePrefix)); 661 else // FIXME: Shouldn't this case be an error? 662 $$->tag = QualifiedName(nullAtom, atomicString($3), p->defaultNamespace); 654 663 } 655 664 } … … 657 666 $$ = $3; 658 667 if ($$) { 659 $$->tag = makeId(anyNamespace, anyLocalName);668 AtomicString namespacePrefix = atomicString($1); 660 669 CSSParser *p = static_cast<CSSParser *>(parser); 661 670 if (p->styleElement && p->styleElement->isCSSStyleSheet()) 662 static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->tag, domString($1)); 671 $$->tag = QualifiedName(namespacePrefix, 672 starAtom, 673 static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace(namespacePrefix)); 663 674 } 664 675 } … … 667 678 element_name: 668 679 IDENT { 669 CSSParser *p = static_cast<CSSParser *>(parser); 680 ParseString& str = $1; 681 CSSParser *p = static_cast<CSSParser *>(parser); 670 682 DOM::DocumentImpl *doc = p->document(); 671 QString tag = qString($1); 672 if ( doc ) { 673 if (doc->isHTMLDocument()) 674 tag = tag.lower(); 675 const DOMString dtag(tag); 676 $$ = makeId(p->defaultNamespace, doc->tagId(0, dtag.implementation(), false)); 677 } else { 678 $$ = makeId(p->defaultNamespace, khtml::getTagID(tag.lower().ascii(), tag.length())); 679 // this case should never happen - only when loading 680 // the default stylesheet - which must not contain unknown tags 681 // assert($$ != 0); 682 } 683 if (doc && doc->isHTMLDocument()) 684 str.lower(); 685 $$ = str; 683 686 } 684 687 | '*' { 685 $$ = makeId(static_cast<CSSParser*>(parser)->defaultNamespace, anyLocalName); 688 static unsigned short star = '*'; 689 $$.string = ☆ 690 $$.length = 1; 686 691 } 687 692 ; … … 770 775 $$->attr = $5; 771 776 $$->match = CSSSelector::Set; 772 CSSParser *p = static_cast<CSSParser *>(parser); 773 if (p->styleElement && p->styleElement->isCSSStyleSheet()) 774 static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->attr, domString($3)); 777 // FIXME: For now we're breaking namespace support on attributes. When we switch to atomicstring, then we can make 778 // it work again. 779 //CSSParser *p = static_cast<CSSParser *>(parser); 780 //if (p->styleElement && p->styleElement->isCSSStyleSheet()) 781 // static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->attr, domString($3)); 775 782 } 776 783 | '[' maybe_space namespace_selector '|' attrib_id match maybe_space ident_or_string maybe_space ']' { … … 779 786 $$->match = (CSSSelector::Match)$6; 780 787 $$->value = atomicString($8); 781 CSSParser *p = static_cast<CSSParser *>(parser); 782 if (p->styleElement && p->styleElement->isCSSStyleSheet()) 783 static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->attr, domString($3)); 788 // FIXME: For now we're breaking namespace support on attributes. When we switch to atomicstring, then we can make 789 // it work again. 790 //CSSParser *p = static_cast<CSSParser *>(parser); 791 //if (p->styleElement && p->styleElement->isCSSStyleSheet()) 792 // static_cast<CSSStyleSheetImpl*>(p->styleElement)->determineNamespace($$->attr, domString($3)); 784 793 } 785 794 ; -
trunk/WebCore/khtml/dom/css_stylesheet.cpp
r6647 r9639 386 386 // ### check link is really linking a style sheet 387 387 if( n && n->isElementNode() && 388 (n-> id() == ID_STYLE || n->id() == ID_LINK)) {388 (n->hasTagName(HTMLNames::style()) || n->hasTagName(HTMLNames::link()))) { 389 389 node = n; 390 390 if(node) node->ref(); … … 400 400 StyleSheet LinkStyle::sheet() 401 401 { 402 int id = node ? node->id() : 0; 402 if (!node) 403 return StyleSheet(); 404 403 405 // ### add PI 404 406 return 405 ( id == ID_STYLE) ?407 (node->hasTagName(HTMLNames::style())) ? 406 408 static_cast<HTMLStyleElementImpl *>(node)->sheet() 407 : ( (id == ID_LINK) ?409 : ( node->hasTagName(HTMLNames::link()) ? 408 410 static_cast<HTMLLinkElementImpl *>(node)->sheet() 409 411 : StyleSheet() ); -
trunk/WebCore/khtml/dom/dom_element.cpp
r9165 r9639 142 142 { 143 143 if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); 144 return static_cast<ElementImpl*>(impl)-> tagName();144 return static_cast<ElementImpl*>(impl)->nodeName(); 145 145 } 146 146 -
trunk/WebCore/khtml/dom/dom_node.cpp
r9156 r9639 325 325 { 326 326 if (!impl) return DOMString(); 327 return impl-> getDocument()->namespaceURI(impl->id());327 return impl->namespaceURI(); 328 328 } 329 329 … … 338 338 if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR); 339 339 int exceptioncode = 0; 340 impl->setPrefix(prefix ,exceptioncode);340 impl->setPrefix(prefix.implementation(),exceptioncode); 341 341 if (exceptioncode) 342 342 throw DOMException(exceptioncode); … … 377 377 } 378 378 379 380 unsigned int Node::elementId() const381 {382 if (!impl) return 0;383 return impl->id();384 }385 386 379 unsigned long Node::index() const 387 380 { -
trunk/WebCore/khtml/dom/dom_node.h
r9178 r9639 856 856 857 857 /** 858 * @internal859 * not part of the DOM.860 * @returns the element id, in case this is an element, 0 otherwise861 */862 Q_UINT32 elementId() const;863 864 /**865 858 * tests if this Node is 0. Useful especially, if casting to a derived 866 859 * class: -
trunk/WebCore/khtml/dom/html_base.cpp
r5360 r9639 42 42 HTMLBodyElement &HTMLBodyElement::operator = (const Node &other) 43 43 { 44 assignOther( other, ID_BODY);44 assignOther( other, HTMLNames::body() ); 45 45 return *this; 46 46 } … … 136 136 HTMLFrameElement &HTMLFrameElement::operator = (const Node &other) 137 137 { 138 assignOther( other, ID_FRAME);138 assignOther( other, HTMLNames::frame() ); 139 139 return *this; 140 140 } … … 266 266 HTMLIFrameElement &HTMLIFrameElement::operator = (const Node &other) 267 267 { 268 assignOther( other, ID_IFRAME);268 assignOther( other, HTMLNames::iframe() ); 269 269 return *this; 270 270 } … … 415 415 HTMLFrameSetElement &HTMLFrameSetElement::operator = (const Node &other) 416 416 { 417 assignOther( other, ID_FRAMESET);417 assignOther( other, HTMLNames::frameset() ); 418 418 return *this; 419 419 } … … 467 467 HTMLHeadElement &HTMLHeadElement::operator = (const Node &other) 468 468 { 469 assignOther( other, ID_HEAD);469 assignOther( other, HTMLNames::head() ); 470 470 return *this; 471 471 } … … 508 508 HTMLHtmlElement &HTMLHtmlElement::operator = (const Node &other) 509 509 { 510 assignOther( other, ID_HTML);510 assignOther( other, HTMLNames::html() ); 511 511 return *this; 512 512 } -
trunk/WebCore/khtml/dom/html_block.cpp
r1326 r9639 44 44 HTMLBlockquoteElement &HTMLBlockquoteElement::operator = (const Node &other) 45 45 { 46 assignOther( other, ID_BLOCKQUOTE);46 assignOther( other, HTMLNames::blockquote() ); 47 47 return *this; 48 48 } … … 85 85 HTMLDivElement &HTMLDivElement::operator = (const Node &other) 86 86 { 87 assignOther( other, ID_DIV);87 assignOther( other, HTMLNames::div() ); 88 88 return *this; 89 89 } … … 126 126 HTMLHRElement &HTMLHRElement::operator = (const Node &other) 127 127 { 128 assignOther( other, ID_HR);128 assignOther( other, HTMLNames::hr() ); 129 129 return *this; 130 130 } … … 206 206 HTMLHeadingElement &HTMLHeadingElement::operator = (const Node &other) 207 207 { 208 if (other.elementId() != ID_H1 ||209 other.elementId() != ID_H2 ||210 other.elementId() != ID_H3 ||211 other.elementId() != ID_H4 ||212 other.elementId() != ID_H5 ||213 other.elementId() != ID_H6)208 if (!other.handle()->hasTagName(HTMLNames::h1()) && 209 !other.handle()->hasTagName(HTMLNames::h2()) && 210 !other.handle()->hasTagName(HTMLNames::h3()) && 211 !other.handle()->hasTagName(HTMLNames::h4()) && 212 !other.handle()->hasTagName(HTMLNames::h5()) && 213 !other.handle()->hasTagName(HTMLNames::h6())) 214 214 { 215 215 if ( impl ) impl->deref(); 216 216 impl = 0; 217 217 } else { 218 218 219 Node::operator = (other); 219 220 } … … 258 259 HTMLParagraphElement &HTMLParagraphElement::operator = (const Node &other) 259 260 { 260 assignOther( other, ID_P);261 assignOther( other, HTMLNames::p() ); 261 262 return *this; 262 263 } … … 299 300 HTMLPreElement &HTMLPreElement::operator = (const Node &other) 300 301 { 301 assignOther( other, ID_PRE);302 assignOther( other, HTMLNames::pre() ); 302 303 return *this; 303 304 } -
trunk/WebCore/khtml/dom/html_element.cpp
r9156 r9639 183 183 } 184 184 185 void HTMLElement::assignOther( const Node &other, int elementId)186 { 187 if ((int)other.elementId() != elementId) {185 void HTMLElement::assignOther( const Node &other, const QualifiedName& tagName ) 186 { 187 if (!other.handle()->hasTagName(tagName)) { 188 188 if ( impl ) impl->deref(); 189 189 impl = 0; -
trunk/WebCore/khtml/dom/html_element.h
r6666 r9639 31 31 32 32 #include <dom/dom_element.h> 33 #include "dom_qname.h" 34 33 35 class KHTMLView; 34 36 … … 226 228 * @internal 227 229 */ 228 void assignOther( const Node &other, int elementId);230 void assignOther( const Node &other, const QualifiedName& tagName ); 229 231 }; 230 232 -
trunk/WebCore/khtml/dom/html_form.cpp
r9156 r9639 48 48 HTMLButtonElement &HTMLButtonElement::operator = (const Node &other) 49 49 { 50 assignOther( other, ID_BUTTON);50 assignOther( other, HTMLNames::button() ); 51 51 return *this; 52 52 } … … 158 158 HTMLFieldSetElement &HTMLFieldSetElement::operator = (const Node &other) 159 159 { 160 assignOther( other, ID_FIELDSET);160 assignOther( other, HTMLNames::fieldset() ); 161 161 return *this; 162 162 } … … 194 194 HTMLFormElement &HTMLFormElement::operator = (const Node &other) 195 195 { 196 assignOther( other, ID_FORM);196 assignOther( other, HTMLNames::form() ); 197 197 return *this; 198 198 } … … 312 312 HTMLInputElement &HTMLInputElement::operator = (const Node &other) 313 313 { 314 assignOther( other, ID_INPUT);314 assignOther( other, HTMLNames::input() ); 315 315 return *this; 316 316 } … … 575 575 HTMLLabelElement &HTMLLabelElement::operator = (const Node &other) 576 576 { 577 assignOther( other, ID_LABEL);577 assignOther( other, HTMLNames::label() ); 578 578 return *this; 579 579 } … … 634 634 HTMLLegendElement &HTMLLegendElement::operator = (const Node &other) 635 635 { 636 assignOther( other, ID_LEGEND);636 assignOther( other, HTMLNames::legend() ); 637 637 return *this; 638 638 } … … 692 692 HTMLOptGroupElement &HTMLOptGroupElement::operator = (const Node &other) 693 693 { 694 assignOther( other, ID_OPTGROUP);694 assignOther( other, HTMLNames::optgroup() ); 695 695 return *this; 696 696 } … … 745 745 HTMLSelectElement &HTMLSelectElement::operator = (const Node &other) 746 746 { 747 assignOther( other, ID_SELECT);747 assignOther( other, HTMLNames::select() ); 748 748 return *this; 749 749 } … … 907 907 HTMLTextAreaElement &HTMLTextAreaElement::operator = (const Node &other) 908 908 { 909 assignOther( other, ID_TEXTAREA);909 assignOther( other, HTMLNames::textarea() ); 910 910 return *this; 911 911 } … … 1075 1075 HTMLOptionElement &HTMLOptionElement::operator = (const Node &other) 1076 1076 { 1077 assignOther( other, ID_OPTION);1077 assignOther( other, HTMLNames::option() ); 1078 1078 return *this; 1079 1079 } … … 1183 1183 HTMLIsIndexElement &HTMLIsIndexElement::operator = (const Node &other) 1184 1184 { 1185 assignOther( other, ID_ISINDEX);1185 assignOther( other, HTMLNames::isindex() ); 1186 1186 return *this; 1187 1187 } -
trunk/WebCore/khtml/dom/html_head.cpp
r9466 r9639 43 43 HTMLBaseElement &HTMLBaseElement::operator = (const Node &other) 44 44 { 45 assignOther( other, ID_BASE);45 assignOther( other, HTMLNames::base() ); 46 46 return *this; 47 47 } … … 98 98 HTMLLinkElement &HTMLLinkElement::operator = (const Node &other) 99 99 { 100 assignOther( other, ID_LINK);100 assignOther( other, HTMLNames::link() ); 101 101 return *this; 102 102 } … … 239 239 HTMLMetaElement &HTMLMetaElement::operator = (const Node &other) 240 240 { 241 assignOther( other, ID_META);241 assignOther( other, HTMLNames::meta() ); 242 242 return *this; 243 243 } … … 313 313 HTMLScriptElement &HTMLScriptElement::operator = (const Node &other) 314 314 { 315 assignOther( other, ID_SCRIPT);315 assignOther( other, HTMLNames::script() ); 316 316 return *this; 317 317 } … … 425 425 HTMLStyleElement &HTMLStyleElement::operator = (const Node &other) 426 426 { 427 assignOther( other, ID_STYLE);427 assignOther( other, HTMLNames::style() ); 428 428 return *this; 429 429 } … … 497 497 HTMLTitleElement &HTMLTitleElement::operator = (const Node &other) 498 498 { 499 assignOther( other, ID_TITLE);499 assignOther( other, HTMLNames::title() ); 500 500 return *this; 501 501 } -
trunk/WebCore/khtml/dom/html_image.cpp
r5360 r9639 47 47 HTMLAreaElement &HTMLAreaElement::operator = (const Node &other) 48 48 { 49 assignOther( other, ID_AREA);49 assignOther( other, HTMLNames::area() ); 50 50 return *this; 51 51 } … … 177 177 HTMLImageElement &HTMLImageElement::operator = (const Node &other) 178 178 { 179 assignOther( other, ID_IMG);179 assignOther( other, HTMLNames::img() ); 180 180 return *this; 181 181 } … … 373 373 HTMLMapElement &HTMLMapElement::operator = (const Node &other) 374 374 { 375 assignOther( other, ID_MAP);375 assignOther( other, HTMLNames::map() ); 376 376 return *this; 377 377 } -
trunk/WebCore/khtml/dom/html_inline.cpp
r9156 r9639 46 46 HTMLAnchorElement &HTMLAnchorElement::operator = (const Node &other) 47 47 { 48 assignOther( other, ID_A);48 assignOther( other, HTMLNames::a() ); 49 49 return *this; 50 50 } … … 218 218 HTMLBRElement &HTMLBRElement::operator = (const Node &other) 219 219 { 220 assignOther( other, ID_BR);220 assignOther( other, HTMLNames::br() ); 221 221 return *this; 222 222 } … … 259 259 HTMLFontElement &HTMLFontElement::operator = (const Node &other) 260 260 { 261 assignOther( other, ID_FONT);261 assignOther( other, HTMLNames::font() ); 262 262 return *this; 263 263 } … … 320 320 : HTMLElement() 321 321 { 322 if (_impl && (_impl-> id() == ID_INS || _impl->id() == ID_DEL))322 if (_impl && (_impl->hasTagName(HTMLNames::ins()) || _impl->hasTagName(HTMLNames::del()))) 323 323 impl = _impl; 324 324 else … … 329 329 HTMLModElement &HTMLModElement::operator = (const Node &other) 330 330 { 331 if( other.elementId() != ID_INS && 332 other.elementId() != ID_DEL ) 333 { 331 if (!other.handle()->hasTagName(HTMLNames::ins()) && 332 !other.handle()->hasTagName(HTMLNames::del())) { 334 333 if ( impl ) impl->deref(); 335 334 impl = 0; … … 382 381 } 383 382 384 HTMLQuoteElement::HTMLQuoteElement(HTML GenericElementImpl *_impl)383 HTMLQuoteElement::HTMLQuoteElement(HTMLQuoteElementImpl *_impl) 385 384 : HTMLElement() 386 385 { 387 if (_impl && _impl->id() == ID_Q) 388 impl = _impl; 389 else 390 impl = 0; 386 impl = _impl; 391 387 if ( impl ) impl->ref(); 392 388 } … … 394 390 HTMLQuoteElement &HTMLQuoteElement::operator = (const Node &other) 395 391 { 396 assignOther( other, ID_Q);392 assignOther( other, HTMLNames::q() ); 397 393 return *this; 398 394 } -
trunk/WebCore/khtml/dom/html_inline.h
r1024 r9639 426 426 {(*this)=other;} 427 427 protected: 428 HTMLQuoteElement(HTML GenericElementImpl *impl);428 HTMLQuoteElement(HTMLQuoteElementImpl *impl); 429 429 public: 430 430 -
trunk/WebCore/khtml/dom/html_list.cpp
r1326 r9639 42 42 HTMLDListElement &HTMLDListElement::operator = (const Node &other) 43 43 { 44 assignOther( other, ID_DL);44 assignOther( other, HTMLNames::dl() ); 45 45 return *this; 46 46 } … … 89 89 HTMLDirectoryElement &HTMLDirectoryElement::operator = (const Node &other) 90 90 { 91 assignOther( other, ID_DIR);91 assignOther( other, HTMLNames::dir() ); 92 92 return *this; 93 93 } … … 136 136 HTMLLIElement &HTMLLIElement::operator = (const Node &other) 137 137 { 138 assignOther( other, ID_LI);138 assignOther( other, HTMLNames::li() ); 139 139 return *this; 140 140 } … … 191 191 HTMLMenuElement &HTMLMenuElement::operator = (const Node &other) 192 192 { 193 assignOther( other, ID_MENU);193 assignOther( other, HTMLNames::menu() ); 194 194 return *this; 195 195 } … … 238 238 HTMLOListElement &HTMLOListElement::operator = (const Node &other) 239 239 { 240 assignOther( other, ID_OL);240 assignOther( other, HTMLNames::ol() ); 241 241 return *this; 242 242 } … … 311 311 HTMLUListElement &HTMLUListElement::operator = (const Node &other) 312 312 { 313 assignOther( other, ID_UL);313 assignOther( other, HTMLNames::ul() ); 314 314 return *this; 315 315 } -
trunk/WebCore/khtml/dom/html_misc.cpp
r9156 r9639 42 42 HTMLBaseFontElement &HTMLBaseFontElement::operator = (const Node &other) 43 43 { 44 assignOther( other, ID_BASEFONT);44 assignOther( other, HTMLNames::basefont() ); 45 45 return *this; 46 46 } -
trunk/WebCore/khtml/dom/html_object.cpp
r6135 r9639 44 44 HTMLAppletElement &HTMLAppletElement::operator = (const Node &other) 45 45 { 46 assignOther( other, ID_APPLET);46 assignOther( other, HTMLNames::applet() ); 47 47 return *this; 48 48 } … … 195 195 HTMLObjectElement &HTMLObjectElement::operator = (const Node &other) 196 196 { 197 assignOther( other, ID_OBJECT);197 assignOther( other, HTMLNames::object() ); 198 198 return *this; 199 199 } … … 433 433 HTMLParamElement &HTMLParamElement::operator = (const Node &other) 434 434 { 435 assignOther( other, ID_PARAM);435 assignOther( other, HTMLNames::param() ); 436 436 return *this; 437 437 } -
trunk/WebCore/khtml/dom/html_table.cpp
r5334 r9639 46 46 HTMLTableCaptionElement &HTMLTableCaptionElement::operator = (const Node &other) 47 47 { 48 assignOther( other, ID_CAPTION);48 assignOther( other, HTMLNames::caption() ); 49 49 return *this; 50 50 } … … 87 87 HTMLTableCellElement &HTMLTableCellElement::operator = (const Node &other) 88 88 { 89 if( other.elementId() != ID_TD && 90 other.elementId() != ID_TH ) 91 { 89 if (!other.handle()->hasTagName(HTMLNames::td()) || 90 !other.handle()->hasTagName(HTMLNames::th())) { 92 91 if ( impl ) impl->deref(); 93 92 impl = 0; … … 296 295 HTMLTableColElement &HTMLTableColElement::operator = (const Node &other) 297 296 { 298 if( other.elementId() != ID_COL && 299 other.elementId() != ID_COLGROUP ) 300 { 297 if (!other.handle()->hasTagName(HTMLNames::col()) && 298 !other.handle()->hasTagName(HTMLNames::colgroup())) { 301 299 if ( impl ) impl->deref(); 302 300 impl = 0; … … 402 400 HTMLTableElement &HTMLTableElement::operator = (const Node &other) 403 401 { 404 assignOther( other, ID_TABLE);402 assignOther( other, HTMLNames::table() ); 405 403 return *this; 406 404 } … … 639 637 HTMLTableRowElement &HTMLTableRowElement::operator = (const Node &other) 640 638 { 641 assignOther( other, ID_TR);639 assignOther( other, HTMLNames::tr() ); 642 640 return *this; 643 641 } … … 776 774 HTMLTableSectionElement &HTMLTableSectionElement::operator = (const Node &other) 777 775 { 778 if(other.elementId() != ID_TBODY && 779 other.elementId() != ID_THEAD && 780 other.elementId() != ID_TFOOT ) 781 { 776 if (!other.handle()->hasTagName(HTMLNames::tbody()) && 777 !other.handle()->hasTagName(HTMLNames::thead()) && 778 !other.handle()->hasTagName(HTMLNames::tfoot())) { 782 779 if ( impl ) impl->deref(); 783 780 impl = 0; -
trunk/WebCore/khtml/ecma/kjs_css.cpp
r9582 r9639 30 30 #include "html/html_headimpl.h" // for HTMLStyleElement 31 31 #include "kjs_dom.h" 32 #include " misc/htmltags.h"32 #include "htmlnames.h" 33 33 34 34 #include <kdebug.h> … … 56 56 using DOM::DOMString; 57 57 using DOM::ElementImpl; 58 using DOM::HTMLNames; 58 59 using DOM::HTMLStyleElementImpl; 59 60 using DOM::MediaListImpl; … … 405 406 // But unicity of stylesheet ids is good practice anyway ;) 406 407 ElementImpl *element = m_doc->getElementById(p.string()); 407 if (element && element-> id() == ID_STYLE)408 if (element && element->hasTagName(HTMLNames::style())) 408 409 return getDOMStyleSheet(exec, static_cast<HTMLStyleElementImpl *>(element)->sheet()); 409 410 -
trunk/WebCore/khtml/ecma/kjs_dom.cpp
r9582 r9639 48 48 #include "html_objectimpl.h" 49 49 50 #include "misc/htmltags.h"51 52 50 #if APPLE_CHANGES 53 51 #include <JavaScriptCore/runtime_object.h> … … 68 66 using DOM::HTMLElementImpl; 69 67 using DOM::HTMLEmbedElementImpl; 68 using DOM::HTMLNames; 70 69 using DOM::HTMLObjectElementImpl; 71 70 using DOM::NamedNodeMapImpl; … … 463 462 break; 464 463 case Prefix: 465 node.setPrefix(value.toString(exec).string() , exception);464 node.setPrefix(value.toString(exec).string().implementation(), exception); 466 465 break; 467 466 case OnAbort: … … 1188 1187 switch( entry->value ) { 1189 1188 case TagName: 1190 return getStringOrNull(element. tagName());1189 return getStringOrNull(element.nodeName()); 1191 1190 case Style: 1192 1191 return getDOMCSSStyleDeclaration(exec,element.style()); … … 1711 1710 return 0; 1712 1711 1713 switch (n->id()) { 1714 case ID_APPLET: { 1715 HTMLAppletElementImpl *appletElement = static_cast<HTMLAppletElementImpl *>(n); 1716 if (appletElement->getAppletInstance()) 1717 // The instance is owned by the applet element. 1718 return new RuntimeObjectImp(appletElement->getAppletInstance(), false); 1719 break; 1720 } 1721 case ID_EMBED: { 1722 HTMLEmbedElementImpl *embedElement = static_cast<HTMLEmbedElementImpl *>(n); 1723 if (embedElement->getEmbedInstance()) 1724 return new RuntimeObjectImp(embedElement->getEmbedInstance(), false); 1725 break; 1726 } 1727 case ID_OBJECT: { 1728 HTMLObjectElementImpl *objectElement = static_cast<HTMLObjectElementImpl *>(n); 1729 if (objectElement->getObjectInstance()) 1730 return new RuntimeObjectImp(objectElement->getObjectInstance(), false); 1731 break; 1732 } 1712 if (n->hasTagName(HTMLNames::applet())) { 1713 HTMLAppletElementImpl *appletElement = static_cast<HTMLAppletElementImpl *>(n); 1714 if (appletElement->getAppletInstance()) 1715 // The instance is owned by the applet element. 1716 return new RuntimeObjectImp(appletElement->getAppletInstance(), false); 1717 } 1718 else if (n->hasTagName(HTMLNames::embed())) { 1719 HTMLEmbedElementImpl *embedElement = static_cast<HTMLEmbedElementImpl *>(n); 1720 if (embedElement->getEmbedInstance()) 1721 return new RuntimeObjectImp(embedElement->getEmbedInstance(), false); 1722 } 1723 else if (n->hasTagName(HTMLNames::object())) { 1724 HTMLObjectElementImpl *objectElement = static_cast<HTMLObjectElementImpl *>(n); 1725 if (objectElement->getObjectInstance()) 1726 return new RuntimeObjectImp(objectElement->getObjectInstance(), false); 1733 1727 } 1734 1728 -
trunk/WebCore/khtml/ecma/kjs_html.cpp
r9582 r9639 46 46 #include "kjs_events.h" 47 47 #include "kjs_proxy.h" 48 49 #include "misc/htmltags.h"50 48 51 49 #include "rendering/render_canvasimage.h" … … 110 108 using DOM::HTMLMetaElementImpl; 111 109 using DOM::HTMLModElementImpl; 110 using DOM::HTMLNames; 112 111 using DOM::HTMLOListElementImpl; 113 112 using DOM::HTMLObjectElementImpl; … … 354 353 return Value(val); 355 354 356 HTMLBodyElementImpl *bodyElement = (body && body-> id() == ID_BODY) ? static_cast<HTMLBodyElementImpl *>(body) : 0;355 HTMLBodyElementImpl *bodyElement = (body && body->hasTagName(HTMLNames::body())) ? static_cast<HTMLBodyElementImpl *>(body) : 0; 357 356 358 357 if (entry) { … … 430 429 HTMLDocumentImpl &doc = *static_cast<HTMLDocumentImpl *>(impl()); 431 430 HTMLElementImpl *body = doc.body(); 432 HTMLBodyElementImpl *bodyElement = (body && body-> id() == ID_BODY) ? static_cast<HTMLBodyElementImpl *>(body) : 0;431 HTMLBodyElementImpl *bodyElement = (body && body->hasTagName(HTMLNames::body())) ? static_cast<HTMLBodyElementImpl *>(body) : 0; 433 432 434 433 switch (token) { … … 584 583 const ClassInfo* KJS::HTMLElement::classInfo() const 585 584 { 586 switch (impl()->id()) { 587 case ID_HTML: 588 return &html_info; 589 case ID_HEAD: 590 return &head_info; 591 case ID_LINK: 592 return &link_info; 593 case ID_TITLE: 594 return &title_info; 595 case ID_META: 596 return &meta_info; 597 case ID_BASE: 598 return &base_info; 599 case ID_ISINDEX: 600 return &isIndex_info; 601 case ID_STYLE: 602 return &style_info; 603 case ID_BODY: 604 return &body_info; 605 case ID_FORM: 606 return &form_info; 607 case ID_SELECT: 608 return &select_info; 609 case ID_OPTGROUP: 610 return &optGroup_info; 611 case ID_OPTION: 612 return &option_info; 613 case ID_INPUT: 614 return &input_info; 615 case ID_TEXTAREA: 616 return &textArea_info; 617 case ID_BUTTON: 618 return &button_info; 619 case ID_LABEL: 620 return &label_info; 621 case ID_FIELDSET: 622 return &fieldSet_info; 623 case ID_LEGEND: 624 return &legend_info; 625 case ID_UL: 626 return &ul_info; 627 case ID_OL: 628 return &ol_info; 629 case ID_DL: 630 return &dl_info; 631 case ID_DIR: 632 return &dir_info; 633 case ID_MENU: 634 return &menu_info; 635 case ID_LI: 636 return &li_info; 637 case ID_DIV: 638 return &div_info; 639 case ID_P: 640 return &p_info; 641 case ID_H1: 642 case ID_H2: 643 case ID_H3: 644 case ID_H4: 645 case ID_H5: 646 case ID_H6: 647 return &heading_info; 648 case ID_BLOCKQUOTE: 649 return &blockQuote_info; 650 case ID_Q: 651 return &q_info; 652 case ID_PRE: 653 return &pre_info; 654 case ID_BR: 655 return &br_info; 656 case ID_BASEFONT: 657 return &baseFont_info; 658 case ID_FONT: 659 return &font_info; 660 case ID_HR: 661 return &hr_info; 662 case ID_INS: 663 case ID_DEL: 664 return &mod_info; 665 case ID_A: 666 return &a_info; 667 case ID_CANVAS: 668 return &canvas_info; 669 case ID_IMG: 670 return &img_info; 671 case ID_OBJECT: 672 return &object_info; 673 case ID_PARAM: 674 return ¶m_info; 675 case ID_APPLET: 676 return &applet_info; 677 case ID_MAP: 678 return &map_info; 679 case ID_AREA: 680 return &area_info; 681 case ID_SCRIPT: 682 return &script_info; 683 case ID_TABLE: 684 return &table_info; 685 case ID_CAPTION: 686 return &caption_info; 687 case ID_COL: 688 return &col_info; 689 case ID_THEAD: 690 return &tablesection_info; 691 case ID_TBODY: 692 return &tablesection_info; 693 case ID_TFOOT: 694 return &tablesection_info; 695 case ID_TR: 696 return &tr_info; 697 case ID_TH: 698 return &tablecell_info; 699 case ID_TD: 700 return &tablecell_info; 701 case ID_FRAMESET: 702 return &frameSet_info; 703 case ID_FRAME: 704 return &frame_info; 705 case ID_IFRAME: 706 return &iFrame_info; 707 case ID_MARQUEE: 708 return &marquee_info; 709 default: 585 // FIXME: We want to use HashMap here, but there are compiler issues to deal with. 586 static QPtrDict<const ClassInfo> classInfoDict; 587 if (classInfoDict.isEmpty()) { 588 classInfoDict.insert(HTMLNames::a().localName().implementation(), &a_info); 589 classInfoDict.insert(HTMLNames::applet().localName().implementation(), &applet_info); 590 classInfoDict.insert(HTMLNames::area().localName().implementation(), &area_info); 591 classInfoDict.insert(HTMLNames::base().localName().implementation(), &base_info); 592 classInfoDict.insert(HTMLNames::basefont().localName().implementation(), &baseFont_info); 593 classInfoDict.insert(HTMLNames::blockquote().localName().implementation(), &blockQuote_info); 594 classInfoDict.insert(HTMLNames::body().localName().implementation(), &body_info); 595 classInfoDict.insert(HTMLNames::br().localName().implementation(), &br_info); 596 classInfoDict.insert(HTMLNames::button().localName().implementation(), &button_info); 597 classInfoDict.insert(HTMLNames::canvas().localName().implementation(), &canvas_info); 598 classInfoDict.insert(HTMLNames::caption().localName().implementation(), &caption_info); 599 classInfoDict.insert(HTMLNames::col().localName().implementation(), &col_info); 600 classInfoDict.insert(HTMLNames::colgroup().localName().implementation(), &col_info); 601 classInfoDict.insert(HTMLNames::del().localName().implementation(), &mod_info); 602 classInfoDict.insert(HTMLNames::dir().localName().implementation(), &dir_info); 603 classInfoDict.insert(HTMLNames::div().localName().implementation(), &div_info); 604 classInfoDict.insert(HTMLNames::dl().localName().implementation(), &dl_info); 605 classInfoDict.insert(HTMLNames::fieldset().localName().implementation(), &fieldSet_info); 606 classInfoDict.insert(HTMLNames::font().localName().implementation(), &font_info); 607 classInfoDict.insert(HTMLNames::form().localName().implementation(), &form_info); 608 classInfoDict.insert(HTMLNames::frame().localName().implementation(), &frame_info); 609 classInfoDict.insert(HTMLNames::frameset().localName().implementation(), &frameSet_info); 610 classInfoDict.insert(HTMLNames::h1().localName().implementation(), &heading_info); 611 classInfoDict.insert(HTMLNames::h2().localName().implementation(), &heading_info); 612 classInfoDict.insert(HTMLNames::h3().localName().implementation(), &heading_info); 613 classInfoDict.insert(HTMLNames::h4().localName().implementation(), &heading_info); 614 classInfoDict.insert(HTMLNames::h5().localName().implementation(), &heading_info); 615 classInfoDict.insert(HTMLNames::h6().localName().implementation(), &heading_info); 616 classInfoDict.insert(HTMLNames::head().localName().implementation(), &head_info); 617 classInfoDict.insert(HTMLNames::hr().localName().implementation(), &hr_info); 618 classInfoDict.insert(HTMLNames::html().localName().implementation(), &html_info); 619 classInfoDict.insert(HTMLNames::iframe().localName().implementation(), &iFrame_info); 620 classInfoDict.insert(HTMLNames::img().localName().implementation(), &img_info); 621 classInfoDict.insert(HTMLNames::input().localName().implementation(), &input_info); 622 classInfoDict.insert(HTMLNames::ins().localName().implementation(), &mod_info); 623 classInfoDict.insert(HTMLNames::isindex().localName().implementation(), &isIndex_info); 624 classInfoDict.insert(HTMLNames::label().localName().implementation(), &label_info); 625 classInfoDict.insert(HTMLNames::legend().localName().implementation(), &legend_info); 626 classInfoDict.insert(HTMLNames::li().localName().implementation(), &li_info); 627 classInfoDict.insert(HTMLNames::link().localName().implementation(), &link_info); 628 classInfoDict.insert(HTMLNames::map().localName().implementation(), &map_info); 629 classInfoDict.insert(HTMLNames::marquee().localName().implementation(), &marquee_info); 630 classInfoDict.insert(HTMLNames::menu().localName().implementation(), &menu_info); 631 classInfoDict.insert(HTMLNames::meta().localName().implementation(), &meta_info); 632 classInfoDict.insert(HTMLNames::object().localName().implementation(), &object_info); 633 classInfoDict.insert(HTMLNames::ol().localName().implementation(), &ol_info); 634 classInfoDict.insert(HTMLNames::option().localName().implementation(), &option_info); 635 classInfoDict.insert(HTMLNames::optgroup().localName().implementation(), &optGroup_info); 636 classInfoDict.insert(HTMLNames::p().localName().implementation(), &p_info); 637 classInfoDict.insert(HTMLNames::param().localName().implementation(), ¶m_info); 638 classInfoDict.insert(HTMLNames::pre().localName().implementation(), &pre_info); 639 classInfoDict.insert(HTMLNames::q().localName().implementation(), &q_info); 640 classInfoDict.insert(HTMLNames::script().localName().implementation(), &script_info); 641 classInfoDict.insert(HTMLNames::select().localName().implementation(), &select_info); 642 classInfoDict.insert(HTMLNames::style().localName().implementation(), &style_info); 643 classInfoDict.insert(HTMLNames::table().localName().implementation(), &table_info); 644 classInfoDict.insert(HTMLNames::tbody().localName().implementation(), &tablesection_info); 645 classInfoDict.insert(HTMLNames::td().localName().implementation(), &tablecell_info); 646 classInfoDict.insert(HTMLNames::textarea().localName().implementation(), &textArea_info); 647 classInfoDict.insert(HTMLNames::th().localName().implementation(), &tablecell_info); 648 classInfoDict.insert(HTMLNames::thead().localName().implementation(), &tablesection_info); 649 classInfoDict.insert(HTMLNames::tfoot().localName().implementation(), &tablesection_info); 650 classInfoDict.insert(HTMLNames::title().localName().implementation(), &title_info); 651 classInfoDict.insert(HTMLNames::tr().localName().implementation(), &tr_info); 652 classInfoDict.insert(HTMLNames::ul().localName().implementation(), &ul_info); 653 } 654 655 HTMLElementImpl* element = static_cast<HTMLElementImpl*>(impl()); 656 const ClassInfo* result = classInfoDict.find(element->localName().implementation()); 657 if (result) 658 return result; 710 659 return &info; 711 } 712 } 660 } 661 662 const HTMLElement::Accessors HTMLElement::html_accessors = { &HTMLElement::htmlGetter, &HTMLElement::htmlSetter }; 663 const HTMLElement::Accessors HTMLElement::head_accessors = { &HTMLElement::headGetter, &HTMLElement::headSetter }; 664 const HTMLElement::Accessors HTMLElement::link_accessors = { &HTMLElement::linkGetter, &HTMLElement::linkSetter }; 665 const HTMLElement::Accessors HTMLElement::title_accessors = { &HTMLElement::titleGetter, &HTMLElement::titleSetter }; 666 const HTMLElement::Accessors HTMLElement::meta_accessors = { &HTMLElement::metaGetter, &HTMLElement::metaSetter }; 667 const HTMLElement::Accessors HTMLElement::base_accessors = { &HTMLElement::baseGetter, &HTMLElement::baseSetter }; 668 const HTMLElement::Accessors HTMLElement::isIndex_accessors = { &HTMLElement::isIndexGetter, &HTMLElement::isIndexSetter }; 669 const HTMLElement::Accessors HTMLElement::style_accessors = { &HTMLElement::styleGetter, &HTMLElement::styleSetter }; 670 const HTMLElement::Accessors HTMLElement::body_accessors = { &HTMLElement::bodyGetter, &HTMLElement::bodySetter }; 671 const HTMLElement::Accessors HTMLElement::form_accessors = { &HTMLElement::formGetter, &HTMLElement::formSetter }; 672 const HTMLElement::Accessors HTMLElement::select_accessors = { &HTMLElement::selectGetter, &HTMLElement::selectSetter }; 673 const HTMLElement::Accessors HTMLElement::optGroup_accessors = { &HTMLElement::optGroupGetter, &HTMLElement::optGroupSetter }; 674 const HTMLElement::Accessors HTMLElement::option_accessors = { &HTMLElement::optionGetter, &HTMLElement::optionSetter }; 675 const HTMLElement::Accessors HTMLElement::input_accessors = { &HTMLElement::inputGetter, &HTMLElement::inputSetter }; 676 const HTMLElement::Accessors HTMLElement::textArea_accessors = { &HTMLElement::textAreaGetter, &HTMLElement::textAreaSetter }; 677 const HTMLElement::Accessors HTMLElement::button_accessors = { &HTMLElement::buttonGetter, &HTMLElement::buttonSetter }; 678 const HTMLElement::Accessors HTMLElement::label_accessors = { &HTMLElement::labelGetter, &HTMLElement::labelSetter }; 679 const HTMLElement::Accessors HTMLElement::fieldSet_accessors = { &HTMLElement::fieldSetGetter, &HTMLElement::fieldSetSetter }; 680 const HTMLElement::Accessors HTMLElement::legend_accessors = { &HTMLElement::legendGetter, &HTMLElement::legendSetter }; 681 const HTMLElement::Accessors HTMLElement::ul_accessors = { &HTMLElement::uListGetter, &HTMLElement::uListSetter }; 682 const HTMLElement::Accessors HTMLElement::ol_accessors = { &HTMLElement::oListGetter, &HTMLElement::oListSetter }; 683 const HTMLElement::Accessors HTMLElement::dl_accessors = { &HTMLElement::dListGetter, &HTMLElement::dListSetter }; 684 const HTMLElement::Accessors HTMLElement::dir_accessors = { &HTMLElement::dirGetter, &HTMLElement::dirSetter }; 685 const HTMLElement::Accessors HTMLElement::menu_accessors = { &HTMLElement::menuGetter, &HTMLElement::menuSetter }; 686 const HTMLElement::Accessors HTMLElement::li_accessors = { &HTMLElement::liGetter, &HTMLElement::liSetter }; 687 const HTMLElement::Accessors HTMLElement::div_accessors = { &HTMLElement::divGetter, &HTMLElement::divSetter }; 688 const HTMLElement::Accessors HTMLElement::p_accessors = { &HTMLElement::paragraphGetter, &HTMLElement::paragraphSetter }; 689 const HTMLElement::Accessors HTMLElement::heading_accessors = { &HTMLElement::headingGetter, &HTMLElement::headingSetter }; 690 const HTMLElement::Accessors HTMLElement::blockQuote_accessors = { &HTMLElement::blockQuoteGetter, &HTMLElement::blockQuoteSetter }; 691 const HTMLElement::Accessors HTMLElement::q_accessors = { &HTMLElement::quoteGetter, &HTMLElement::quoteSetter }; 692 const HTMLElement::Accessors HTMLElement::pre_accessors = { &HTMLElement::preGetter, &HTMLElement::preSetter }; 693 const HTMLElement::Accessors HTMLElement::br_accessors = { &HTMLElement::brGetter, &HTMLElement::brSetter }; 694 const HTMLElement::Accessors HTMLElement::baseFont_accessors = { &HTMLElement::baseFontGetter, &HTMLElement::baseFontSetter }; 695 const HTMLElement::Accessors HTMLElement::font_accessors = { &HTMLElement::fontGetter, &HTMLElement::fontSetter }; 696 const HTMLElement::Accessors HTMLElement::hr_accessors = { &HTMLElement::hrGetter, &HTMLElement::hrSetter }; 697 const HTMLElement::Accessors HTMLElement::mod_accessors = { &HTMLElement::modGetter, &HTMLElement::modSetter }; 698 const HTMLElement::Accessors HTMLElement::a_accessors = { &HTMLElement::anchorGetter, &HTMLElement::anchorSetter }; 699 const HTMLElement::Accessors HTMLElement::canvas_accessors = { &HTMLElement::imageGetter, &HTMLElement::imageSetter }; 700 const HTMLElement::Accessors HTMLElement::img_accessors = { &HTMLElement::imageGetter, &HTMLElement::imageSetter }; 701 const HTMLElement::Accessors HTMLElement::object_accessors = { &HTMLElement::objectGetter, &HTMLElement::objectSetter }; 702 const HTMLElement::Accessors HTMLElement::param_accessors = { &HTMLElement::paramGetter, &HTMLElement::paramSetter }; 703 const HTMLElement::Accessors HTMLElement::applet_accessors = { &HTMLElement::appletGetter, &HTMLElement::appletSetter }; 704 const HTMLElement::Accessors HTMLElement::map_accessors = { &HTMLElement::mapGetter, &HTMLElement::mapSetter }; 705 const HTMLElement::Accessors HTMLElement::area_accessors = { &HTMLElement::areaGetter, &HTMLElement::areaSetter }; 706 const HTMLElement::Accessors HTMLElement::script_accessors = { &HTMLElement::scriptGetter, &HTMLElement::scriptSetter }; 707 const HTMLElement::Accessors HTMLElement::table_accessors = { &HTMLElement::tableGetter, &HTMLElement::tableSetter }; 708 const HTMLElement::Accessors HTMLElement::caption_accessors = { &HTMLElement::tableCaptionGetter, &HTMLElement::tableCaptionSetter }; 709 const HTMLElement::Accessors HTMLElement::col_accessors = { &HTMLElement::tableColGetter, &HTMLElement::tableColSetter }; 710 const HTMLElement::Accessors HTMLElement::tablesection_accessors = { &HTMLElement::tableSectionGetter, &HTMLElement::tableSectionSetter }; 711 const HTMLElement::Accessors HTMLElement::tr_accessors = { &HTMLElement::tableRowGetter, &HTMLElement::tableRowSetter }; 712 const HTMLElement::Accessors HTMLElement::tablecell_accessors = { &HTMLElement::tableCellGetter, &HTMLElement::tableCellSetter }; 713 const HTMLElement::Accessors HTMLElement::frameSet_accessors = { &HTMLElement::frameSetGetter, &HTMLElement::frameSetSetter }; 714 const HTMLElement::Accessors HTMLElement::frame_accessors = { &HTMLElement::frameGetter, &HTMLElement::frameSetter }; 715 const HTMLElement::Accessors HTMLElement::iFrame_accessors = { &HTMLElement::iFrameGetter, &HTMLElement::iFrameSetter }; 716 const HTMLElement::Accessors HTMLElement::marquee_accessors = { &HTMLElement::marqueeGetter, &HTMLElement::marqueeSetter }; 717 718 const HTMLElement::Accessors* HTMLElement::getSetInfo() const 719 { 720 // FIXME: We want to use HashMap here, but there are compiler issues to deal with. 721 static QPtrDict<const HTMLElement::Accessors> getSetInfoDict; 722 if (getSetInfoDict.isEmpty()) { 723 getSetInfoDict.insert(HTMLNames::a().localName().implementation(), &a_accessors); 724 getSetInfoDict.insert(HTMLNames::applet().localName().implementation(), &applet_accessors); 725 getSetInfoDict.insert(HTMLNames::area().localName().implementation(), &area_accessors); 726 getSetInfoDict.insert(HTMLNames::base().localName().implementation(), &base_accessors); 727 getSetInfoDict.insert(HTMLNames::basefont().localName().implementation(), &baseFont_accessors); 728 getSetInfoDict.insert(HTMLNames::blockquote().localName().implementation(), &blockQuote_accessors); 729 getSetInfoDict.insert(HTMLNames::body().localName().implementation(), &body_accessors); 730 getSetInfoDict.insert(HTMLNames::br().localName().implementation(), &br_accessors); 731 getSetInfoDict.insert(HTMLNames::button().localName().implementation(), &button_accessors); 732 getSetInfoDict.insert(HTMLNames::canvas().localName().implementation(), &canvas_accessors); 733 getSetInfoDict.insert(HTMLNames::caption().localName().implementation(), &caption_accessors); 734 getSetInfoDict.insert(HTMLNames::col().localName().implementation(), &col_accessors); 735 getSetInfoDict.insert(HTMLNames::colgroup().localName().implementation(), &col_accessors); 736 getSetInfoDict.insert(HTMLNames::del().localName().implementation(), &mod_accessors); 737 getSetInfoDict.insert(HTMLNames::dir().localName().implementation(), &dir_accessors); 738 getSetInfoDict.insert(HTMLNames::div().localName().implementation(), &div_accessors); 739 getSetInfoDict.insert(HTMLNames::dl().localName().implementation(), &dl_accessors); 740 getSetInfoDict.insert(HTMLNames::fieldset().localName().implementation(), &fieldSet_accessors); 741 getSetInfoDict.insert(HTMLNames::font().localName().implementation(), &font_accessors); 742 getSetInfoDict.insert(HTMLNames::form().localName().implementation(), &form_accessors); 743 getSetInfoDict.insert(HTMLNames::frame().localName().implementation(), &frame_accessors); 744 getSetInfoDict.insert(HTMLNames::frameset().localName().implementation(), &frameSet_accessors); 745 getSetInfoDict.insert(HTMLNames::h1().localName().implementation(), &heading_accessors); 746 getSetInfoDict.insert(HTMLNames::h2().localName().implementation(), &heading_accessors); 747 getSetInfoDict.insert(HTMLNames::h3().localName().implementation(), &heading_accessors); 748 getSetInfoDict.insert(HTMLNames::h4().localName().implementation(), &heading_accessors); 749 getSetInfoDict.insert(HTMLNames::h5().localName().implementation(), &heading_accessors); 750 getSetInfoDict.insert(HTMLNames::h6().localName().implementation(), &heading_accessors); 751 getSetInfoDict.insert(HTMLNames::head().localName().implementation(), &head_accessors); 752 getSetInfoDict.insert(HTMLNames::hr().localName().implementation(), &hr_accessors); 753 getSetInfoDict.insert(HTMLNames::html().localName().implementation(), &html_accessors); 754 getSetInfoDict.insert(HTMLNames::iframe().localName().implementation(), &iFrame_accessors); 755 getSetInfoDict.insert(HTMLNames::img().localName().implementation(), &img_accessors); 756 getSetInfoDict.insert(HTMLNames::input().localName().implementation(), &input_accessors); 757 getSetInfoDict.insert(HTMLNames::ins().localName().implementation(), &mod_accessors); 758 getSetInfoDict.insert(HTMLNames::isindex().localName().implementation(), &isIndex_accessors); 759 getSetInfoDict.insert(HTMLNames::label().localName().implementation(), &label_accessors); 760 getSetInfoDict.insert(HTMLNames::legend().localName().implementation(), &legend_accessors); 761 getSetInfoDict.insert(HTMLNames::li().localName().implementation(), &li_accessors); 762 getSetInfoDict.insert(HTMLNames::link().localName().implementation(), &link_accessors); 763 getSetInfoDict.insert(HTMLNames::map().localName().implementation(), &map_accessors); 764 getSetInfoDict.insert(HTMLNames::marquee().localName().implementation(), &marquee_accessors); 765 getSetInfoDict.insert(HTMLNames::menu().localName().implementation(), &menu_accessors); 766 getSetInfoDict.insert(HTMLNames::meta().localName().implementation(), &meta_accessors); 767 getSetInfoDict.insert(HTMLNames::object().localName().implementation(), &object_accessors); 768 getSetInfoDict.insert(HTMLNames::ol().localName().implementation(), &ol_accessors); 769 getSetInfoDict.insert(HTMLNames::option().localName().implementation(), &option_accessors); 770 getSetInfoDict.insert(HTMLNames::optgroup().localName().implementation(), &optGroup_accessors); 771 getSetInfoDict.insert(HTMLNames::p().localName().implementation(), &p_accessors); 772 getSetInfoDict.insert(HTMLNames::param().localName().implementation(), ¶m_accessors); 773 getSetInfoDict.insert(HTMLNames::pre().localName().implementation(), &pre_accessors); 774 getSetInfoDict.insert(HTMLNames::q().localName().implementation(), &q_accessors); 775 getSetInfoDict.insert(HTMLNames::script().localName().implementation(), &script_accessors); 776 getSetInfoDict.insert(HTMLNames::select().localName().implementation(), &select_accessors); 777 getSetInfoDict.insert(HTMLNames::style().localName().implementation(), &style_accessors); 778 getSetInfoDict.insert(HTMLNames::table().localName().implementation(), &table_accessors); 779 getSetInfoDict.insert(HTMLNames::tbody().localName().implementation(), &tablesection_accessors); 780 getSetInfoDict.insert(HTMLNames::td().localName().implementation(), &tablecell_accessors); 781 getSetInfoDict.insert(HTMLNames::textarea().localName().implementation(), &textArea_accessors); 782 getSetInfoDict.insert(HTMLNames::th().localName().implementation(), &tablecell_accessors); 783 getSetInfoDict.insert(HTMLNames::thead().localName().implementation(), &tablesection_accessors); 784 getSetInfoDict.insert(HTMLNames::tfoot().localName().implementation(), &tablesection_accessors); 785 getSetInfoDict.insert(HTMLNames::title().localName().implementation(), &title_accessors); 786 getSetInfoDict.insert(HTMLNames::tr().localName().implementation(), &tr_accessors); 787 getSetInfoDict.insert(HTMLNames::ul().localName().implementation(), &ul_accessors); 788 } 789 790 HTMLElementImpl* element = static_cast<HTMLElementImpl*>(impl()); 791 const HTMLElement::Accessors* result = getSetInfoDict.find(element->localName().implementation()); 792 if (result) 793 return result; 794 return 0; 795 } 796 713 797 /* 714 798 @begin HTMLElementTable 14 … … 1185 1269 1186 1270 @begin HTMLCanvasElementTable 1 1187 getContext KJS::HTMLElement::GetContext DontDelete|Function 01271 getContext KJS::HTMLElement::GetContext DontDelete|Function 1 1188 1272 @end 1189 1273 */ … … 1196 1280 Value KJS::HTMLElement::tryGet(ExecState *exec, const Identifier &propertyName) const 1197 1281 { 1198 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl());1282 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl()); 1199 1283 #ifdef KJS_VERBOSE 1200 kdDebug(6070) << "KJS::HTMLElement::tryGet " << propertyName.qstring() << " thisTag=" << element.tagName().string() << endl;1284 kdDebug(6070) << "KJS::HTMLElement::tryGet " << propertyName.qstring() << " thisTag=" << element.tagName().string() << endl; 1201 1285 #endif 1202 // First look at dynamic properties 1203 switch (element.id()) { 1204 case ID_FORM: { 1205 HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element); 1206 // Check if we're retrieving an element (by index or by name) 1207 bool ok; 1208 uint u = propertyName.toULong(&ok); 1209 if (ok) 1210 return getDOMNode(exec, form.elements()->item(u)); 1211 ValueImp *namedItems = HTMLCollection(exec, form.elements().get()).getNamedItems(exec, propertyName); 1212 if (!namedItems->isUndefined()) 1213 return namedItems; 1214 } 1215 break; 1216 case ID_SELECT: { 1217 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 1218 bool ok; 1219 uint u = propertyName.toULong(&ok); 1220 if (ok) 1221 return getDOMNode(exec, select.optionsHTMLCollection()->item(u)); // not specified by DOM(?) but supported in netscape/IE 1222 } 1223 break; 1224 case ID_FRAMESET: { 1286 // First look at dynamic properties 1287 if (element.hasLocalName(HTMLNames::form())) { 1288 HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element); 1289 // Check if we're retrieving an element (by index or by name) 1290 bool ok; 1291 uint u = propertyName.toULong(&ok); 1292 if (ok) 1293 return getDOMNode(exec, form.elements()->item(u)); 1294 ValueImp *namedItems = HTMLCollection(exec, form.elements().get()).getNamedItems(exec, propertyName); 1295 if (!namedItems->isUndefined()) 1296 return namedItems; 1297 } 1298 else if (element.hasLocalName(HTMLNames::select())) { 1299 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 1300 bool ok; 1301 uint u = propertyName.toULong(&ok); 1302 if (ok) 1303 return getDOMNode(exec, select.optionsHTMLCollection()->item(u)); // not specified by DOM(?) but supported in netscape/IE 1304 } 1305 else if (element.hasLocalName(HTMLNames::frameset())) { 1225 1306 NodeImpl *frame = element.children()->namedItem(propertyName.string()); 1226 if (frame && frame-> id() == ID_FRAME) {1307 if (frame && frame->hasTagName(HTMLNames::frame())) { 1227 1308 DocumentImpl* doc = static_cast<HTMLFrameElementImpl *>(frame)->contentDocument(); 1228 1309 if (doc) { … … 1237 1318 } 1238 1319 } 1239 break; 1240 case ID_FRAME: 1241 case ID_IFRAME: { 1320 else if (element.hasLocalName(HTMLNames::frame()) || element.hasLocalName(HTMLNames::iframe())) { 1242 1321 DocumentImpl* doc = static_cast<HTMLFrameElementImpl &>(element).contentDocument(); 1243 if ( doc) {1322 if (doc) { 1244 1323 KHTMLPart* part = doc->part(); 1245 if ( part) {1324 if (part) { 1246 1325 Window *window = Window::retrieveWindow(part); 1247 1326 if (window && window->hasProperty(exec, propertyName)) … … 1250 1329 } 1251 1330 } 1252 break;1253 1331 #if APPLE_CHANGES 1254 case ID_EMBED: 1255 case ID_OBJECT: 1256 case ID_APPLET: { 1257 if (propertyName == "__apple_runtime_object") { 1332 else if (element.hasLocalName(HTMLNames::embed()) || element.hasLocalName(HTMLNames::object()) || 1333 element.hasLocalName(HTMLNames::applet())) { 1334 if (propertyName == "__apple_runtime_object") 1258 1335 return getRuntimeObject(exec,&element); 1259 }1260 1261 1336 Value runtimeObject = getRuntimeObject(exec,&element); 1262 1337 if (!runtimeObject.isNull()) { 1263 1338 ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp()); 1264 if (imp->hasProperty(exec, propertyName)) {1339 if (imp->hasProperty(exec, propertyName)) 1265 1340 return imp->get (exec, propertyName); 1266 }1267 1341 } 1268 1342 } 1269 break;1270 1343 #endif 1271 default: 1272 break; 1273 } 1274 1275 const HashTable* table = classInfo()->propHashTable; // get the right hashtable 1276 const HashEntry* entry = Lookup::findEntry(table, propertyName); 1277 if (entry) { 1278 if (entry->attr & Function) 1279 return lookupOrCreateFunction<KJS::HTMLElementFunction>(exec, propertyName, this, entry->value, entry->params, entry->attr); 1280 return getValueProperty(exec, entry->value); 1281 } 1282 1283 // Base HTMLElement stuff or parent class forward, as usual 1284 return DOMObjectLookupGet<KJS::HTMLElementFunction, KJS::HTMLElement, DOMElement>(exec, propertyName, &HTMLElementTable, this); 1344 1345 const HashTable* table = classInfo()->propHashTable; // get the right hashtable 1346 const HashEntry* entry = Lookup::findEntry(table, propertyName); 1347 if (entry) { 1348 if (entry->attr & Function) 1349 return lookupOrCreateFunction<KJS::HTMLElementFunction>(exec, propertyName, this, entry->value, entry->params, entry->attr); 1350 return getValueProperty(exec, entry->value); 1351 } 1352 1353 // Base HTMLElement stuff or parent class forward, as usual 1354 return DOMObjectLookupGet<KJS::HTMLElementFunction, KJS::HTMLElement, DOMElement>(exec, propertyName, &HTMLElementTable, this); 1285 1355 } 1286 1356 … … 1288 1358 { 1289 1359 HTMLElementImpl *element = static_cast<HTMLElementImpl *>(impl()); 1290 switch (element->id()) { 1291 case ID_EMBED: 1292 case ID_OBJECT: 1293 case ID_APPLET: { 1294 DocumentImpl* doc = element->getDocument(); 1295 KJSProxy *proxy = KJSProxy::proxy(doc->part()); 1296 ExecState *exec = proxy->interpreter()->globalExec(); 1297 Value runtimeObject = getRuntimeObject(exec,element); 1298 if (!runtimeObject.isNull()) { 1299 ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp()); 1300 return imp->implementsCall (); 1301 } 1302 } 1303 break; 1304 default: 1305 break; 1360 if (element->hasTagName(HTMLNames::embed()) || 1361 element->hasTagName(HTMLNames::object()) || 1362 element->hasTagName(HTMLNames::applet())) { 1363 DocumentImpl* doc = element->getDocument(); 1364 KJSProxy *proxy = KJSProxy::proxy(doc->part()); 1365 ExecState *exec = proxy->interpreter()->globalExec(); 1366 Value runtimeObject = getRuntimeObject(exec,element); 1367 if (!runtimeObject.isNull()) { 1368 ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp()); 1369 return imp->implementsCall (); 1370 } 1306 1371 } 1307 1372 return false; … … 1311 1376 { 1312 1377 HTMLElementImpl *element = static_cast<HTMLElementImpl *>(impl()); 1313 switch (element->id()) { 1314 case ID_EMBED: 1315 case ID_OBJECT: 1316 case ID_APPLET: { 1317 Value runtimeObject = getRuntimeObject(exec,element); 1318 if (!runtimeObject.isNull()) { 1319 ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp()); 1320 return imp->call (exec, thisObj, args); 1321 } 1322 } 1323 break; 1324 default: 1325 break; 1378 if (element->hasTagName(HTMLNames::embed()) || 1379 element->hasTagName(HTMLNames::object()) || 1380 element->hasTagName(HTMLNames::applet())) { 1381 Value runtimeObject = getRuntimeObject(exec,element); 1382 if (!runtimeObject.isNull()) { 1383 ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp()); 1384 return imp->call (exec, thisObj, args); 1385 } 1386 } 1387 return Undefined(); 1388 } 1389 1390 Value HTMLElement::htmlGetter(ExecState* exec, int token) const 1391 { 1392 HTMLHtmlElementImpl& html = *static_cast<HTMLHtmlElementImpl*>(impl()); 1393 if (token == HtmlVersion) 1394 return String(html.version()); 1395 return Undefined(); 1396 } 1397 1398 Value HTMLElement::headGetter(ExecState* exec, int token) const 1399 { 1400 HTMLHeadElementImpl &head = *static_cast<HTMLHeadElementImpl*>(impl()); 1401 if (token == HeadProfile) 1402 return String(head.profile()); 1403 return Undefined(); 1404 } 1405 1406 Value HTMLElement::linkGetter(ExecState* exec, int token) const 1407 { 1408 HTMLLinkElementImpl &link = *static_cast<HTMLLinkElementImpl*>(impl()); 1409 switch (token) { 1410 case LinkDisabled: 1411 return Boolean(link.disabled()); 1412 case LinkCharset: 1413 return String(link.charset()); 1414 case LinkHref: 1415 return String(link.href()); 1416 case LinkHrefLang: 1417 return String(link.hreflang()); 1418 case LinkMedia: 1419 return String(link.media()); 1420 case LinkRel: 1421 return String(link.rel()); 1422 case LinkRev: 1423 return String(link.rev()); 1424 case LinkTarget: 1425 return String(link.target()); 1426 case LinkType: 1427 return String(link.type()); 1428 case LinkSheet: 1429 return getDOMStyleSheet(exec, link.sheet()); 1430 } 1431 return Undefined(); 1432 } 1433 1434 Value HTMLElement::titleGetter(ExecState* exec, int token) const 1435 { 1436 HTMLTitleElementImpl& title = *static_cast<HTMLTitleElementImpl*>(impl()); 1437 if (token == TitleText) 1438 return String(title.text()); 1439 return Undefined(); 1440 } 1441 1442 Value HTMLElement::metaGetter(ExecState* exec, int token) const 1443 { 1444 HTMLMetaElementImpl& meta = *static_cast<HTMLMetaElementImpl*>(impl()); 1445 switch (token) { 1446 case MetaContent: return String(meta.content()); 1447 case MetaHttpEquiv: return String(meta.httpEquiv()); 1448 case MetaName: return String(meta.name()); 1449 case MetaScheme: return String(meta.scheme()); 1450 } 1451 return Undefined(); 1452 } 1453 1454 Value HTMLElement::baseGetter(ExecState* exec, int token) const 1455 { 1456 HTMLBaseElementImpl& base = *static_cast<HTMLBaseElementImpl*>(impl()); 1457 switch (token) { 1458 case BaseHref: return String(base.href()); 1459 case BaseTarget: return String(base.target()); 1460 } 1461 return Undefined(); 1462 } 1463 1464 Value HTMLElement::isIndexGetter(ExecState* exec, int token) const 1465 { 1466 HTMLIsIndexElementImpl& isindex = *static_cast<HTMLIsIndexElementImpl*>(impl()); 1467 switch (token) { 1468 case IsIndexForm: return getDOMNode(exec, isindex.form()); // type HTMLFormElement 1469 case IsIndexPrompt: return String(isindex.prompt()); 1470 } 1471 return Undefined(); 1472 } 1473 1474 Value HTMLElement::styleGetter(ExecState* exec, int token) const 1475 { 1476 HTMLStyleElementImpl& style = *static_cast<HTMLStyleElementImpl*>(impl()); 1477 switch (token) { 1478 case StyleDisabled: return Boolean(style.disabled()); 1479 case StyleMedia: return String(style.media()); 1480 case StyleType: return String(style.type()); 1481 case StyleSheet: return getDOMStyleSheet(exec, style.sheet()); 1482 } 1483 return Undefined(); 1484 } 1485 1486 Value HTMLElement::bodyGetter(ExecState* exec, int token) const 1487 { 1488 HTMLBodyElementImpl& body = *static_cast<HTMLBodyElementImpl*>(impl()); 1489 switch (token) { 1490 case BodyALink: return String(body.aLink()); 1491 case BodyBackground: return String(body.background()); 1492 case BodyBgColor: return String(body.bgColor()); 1493 case BodyLink: return String(body.link()); 1494 case BodyText: return String(body.text()); 1495 case BodyVLink: return String(body.vLink()); 1496 default: { 1497 // Update the document's layout before we compute these attributes. 1498 DocumentImpl *doc = body.getDocument(); 1499 if (doc) 1500 doc->updateLayoutIgnorePendingStylesheets(); 1501 KHTMLView *view = doc ? doc->view() : 0; 1502 switch (token) { 1503 case BodyScrollLeft: 1504 return Number(view ? view->contentsX() : 0); 1505 case BodyScrollTop: 1506 return Number(view ? view->contentsY() : 0); 1507 case BodyScrollHeight: 1508 return Number(view ? view->contentsHeight() : 0); 1509 case BodyScrollWidth: 1510 return Number(view ? view->contentsWidth() : 0); 1511 } 1512 } 1513 } 1514 return Undefined(); 1515 } 1516 1517 Value HTMLElement::formGetter(ExecState* exec, int token) const 1518 { 1519 HTMLFormElementImpl& form = *static_cast<HTMLFormElementImpl*>(impl()); 1520 switch (token) { 1521 case FormElements: return getHTMLCollection(exec, form.elements().get()); 1522 case FormLength: return Number(form.length()); 1523 case FormName: return String(form.name()); 1524 case FormAcceptCharset: return String(form.acceptCharset()); 1525 case FormAction: return String(form.action()); 1526 case FormEncType: return String(form.enctype()); 1527 case FormMethod: return String(form.method()); 1528 case FormTarget: return String(form.target()); 1529 } 1530 return Undefined(); 1531 } 1532 1533 Value HTMLElement::selectGetter(ExecState* exec, int token) const 1534 { 1535 HTMLSelectElementImpl& select = *static_cast<HTMLSelectElementImpl*>(impl()); 1536 switch (token) { 1537 case SelectType: return String(select.type()); 1538 case SelectSelectedIndex: return Number(select.selectedIndex()); 1539 case SelectValue: return String(select.value()); 1540 case SelectLength: return Number(select.length()); 1541 case SelectForm: return getDOMNode(exec, select.form()); // type HTMLFormElement 1542 case SelectOptions: return getSelectHTMLCollection(exec, select.optionsHTMLCollection().get(), &select); // type HTMLCollection 1543 case SelectDisabled: return Boolean(select.disabled()); 1544 case SelectMultiple: return Boolean(select.multiple()); 1545 case SelectName: return String(select.name()); 1546 case SelectSize: return Number(select.size()); 1547 case SelectTabIndex: return Number(select.tabIndex()); 1548 } 1549 return Undefined(); 1550 } 1551 1552 Value HTMLElement::optGroupGetter(ExecState* exec, int token) const 1553 { 1554 HTMLOptGroupElementImpl& optgroup = *static_cast<HTMLOptGroupElementImpl*>(impl()); 1555 switch (token) { 1556 case OptGroupDisabled: return Boolean(optgroup.disabled()); 1557 case OptGroupLabel: return String(optgroup.label()); 1558 } 1559 return Undefined(); 1560 } 1561 1562 Value HTMLElement::optionGetter(ExecState* exec, int token) const 1563 { 1564 HTMLOptionElementImpl& option = *static_cast<HTMLOptionElementImpl*>(impl()); 1565 switch (token) { 1566 case OptionForm: return getDOMNode(exec,option.form()); // type HTMLFormElement 1567 case OptionDefaultSelected: return Boolean(option.defaultSelected()); 1568 case OptionText: return String(option.text()); 1569 case OptionIndex: return Number(option.index()); 1570 case OptionDisabled: return Boolean(option.disabled()); 1571 case OptionLabel: return String(option.label()); 1572 case OptionSelected: return Boolean(option.selected()); 1573 case OptionValue: return String(option.value()); 1326 1574 } 1327 1575 return Undefined(); … … 1330 1578 static Value getInputSelectionStart(HTMLInputElementImpl &input) 1331 1579 { 1332 if (input.canHaveSelection()) { 1333 return Number(input.selectionStart()); 1334 } 1335 return Undefined(); 1580 if (input.canHaveSelection()) 1581 return Number(input.selectionStart()); 1582 return Undefined(); 1336 1583 } 1337 1584 1338 1585 static Value getInputSelectionEnd(HTMLInputElementImpl &input) 1339 1586 { 1340 if (input.canHaveSelection()) { 1341 return Number(input.selectionEnd()); 1342 } 1343 return Undefined(); 1344 } 1345 1346 Value KJS::HTMLElement::getValueProperty(ExecState *exec, int token) const 1347 { 1348 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl()); 1349 switch (element.id()) { 1350 case ID_HTML: { 1351 HTMLHtmlElementImpl &html = static_cast<HTMLHtmlElementImpl &>(element); 1352 if (token == HtmlVersion) return String(html.version()); 1353 } 1354 break; 1355 case ID_HEAD: { 1356 HTMLHeadElementImpl &head = static_cast<HTMLHeadElementImpl &>(element); 1357 if (token == HeadProfile) return String(head.profile()); 1358 } 1359 break; 1360 case ID_LINK: { 1361 HTMLLinkElementImpl &link = static_cast<HTMLLinkElementImpl &>(element); 1362 switch (token) { 1363 case LinkDisabled: return Boolean(link.disabled()); 1364 case LinkCharset: return String(link.charset()); 1365 case LinkHref: return String(link.href()); 1366 case LinkHrefLang: return String(link.hreflang()); 1367 case LinkMedia: return String(link.media()); 1368 case LinkRel: return String(link.rel()); 1369 case LinkRev: return String(link.rev()); 1370 case LinkTarget: return String(link.target()); 1371 case LinkType: return String(link.type()); 1372 case LinkSheet: return getDOMStyleSheet(exec, link.sheet()); 1373 } 1374 } 1375 break; 1376 case ID_TITLE: { 1377 HTMLTitleElementImpl &title = static_cast<HTMLTitleElementImpl &>(element); 1378 switch (token) { 1379 case TitleText: return String(title.text()); 1380 } 1381 } 1382 break; 1383 case ID_META: { 1384 HTMLMetaElementImpl &meta = static_cast<HTMLMetaElementImpl &>(element); 1385 switch (token) { 1386 case MetaContent: return String(meta.content()); 1387 case MetaHttpEquiv: return String(meta.httpEquiv()); 1388 case MetaName: return String(meta.name()); 1389 case MetaScheme: return String(meta.scheme()); 1390 } 1391 } 1392 break; 1393 case ID_BASE: { 1394 HTMLBaseElementImpl &base = static_cast<HTMLBaseElementImpl &>(element); 1395 switch (token) { 1396 case BaseHref: return String(base.href()); 1397 case BaseTarget: return String(base.target()); 1398 } 1399 } 1400 break; 1401 case ID_ISINDEX: { 1402 HTMLIsIndexElementImpl &isindex = static_cast<HTMLIsIndexElementImpl &>(element); 1403 switch (token) { 1404 case IsIndexForm: return getDOMNode(exec, isindex.form()); // type HTMLFormElement 1405 case IsIndexPrompt: return String(isindex.prompt()); 1406 } 1407 } 1408 break; 1409 case ID_STYLE: { 1410 HTMLStyleElementImpl &style = static_cast<HTMLStyleElementImpl &>(element); 1411 switch (token) { 1412 case StyleDisabled: return Boolean(style.disabled()); 1413 case StyleMedia: return String(style.media()); 1414 case StyleType: return String(style.type()); 1415 case StyleSheet: return getDOMStyleSheet(exec, style.sheet()); 1416 } 1417 } 1418 break; 1419 case ID_BODY: { 1420 HTMLBodyElementImpl &body = static_cast<HTMLBodyElementImpl &>(element); 1421 switch (token) { 1422 case BodyALink: return String(body.aLink()); 1423 case BodyBackground: return String(body.background()); 1424 case BodyBgColor: return String(body.bgColor()); 1425 case BodyLink: return String(body.link()); 1426 case BodyText: return String(body.text()); 1427 case BodyVLink: return String(body.vLink()); 1428 default: 1429 // Update the document's layout before we compute these attributes. 1430 DocumentImpl *doc = body.getDocument(); 1431 if (doc) 1432 doc->updateLayoutIgnorePendingStylesheets(); 1433 KHTMLView *view = doc ? doc->view() : 0; 1434 switch (token) { 1435 case BodyScrollLeft: 1436 return Number(view ? view->contentsX() : 0); 1437 case BodyScrollTop: 1438 return Number(view ? view->contentsY() : 0); 1439 case BodyScrollHeight: return Number(view ? view->contentsHeight() : 0); 1440 case BodyScrollWidth: return Number(view ? view->contentsWidth() : 0); 1441 } 1442 } 1443 } 1444 break; 1445 1446 case ID_FORM: { 1447 HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element); 1448 switch (token) { 1449 case FormElements: return getHTMLCollection(exec, form.elements().get()); 1450 case FormLength: return Number(form.length()); 1451 case FormName: return String(form.name()); 1452 case FormAcceptCharset: return String(form.acceptCharset()); 1453 case FormAction: return String(form.action()); 1454 case FormEncType: return String(form.enctype()); 1455 case FormMethod: return String(form.method()); 1456 case FormTarget: return String(form.target()); 1457 } 1458 } 1459 break; 1460 case ID_SELECT: { 1461 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 1462 switch (token) { 1463 case SelectType: return String(select.type()); 1464 case SelectSelectedIndex: return Number(select.selectedIndex()); 1465 case SelectValue: return String(select.value()); 1466 case SelectLength: return Number(select.length()); 1467 case SelectForm: return getDOMNode(exec, select.form()); // type HTMLFormElement 1468 case SelectOptions: return getSelectHTMLCollection(exec, select.optionsHTMLCollection().get(), &select); // type HTMLCollection 1469 case SelectDisabled: return Boolean(select.disabled()); 1470 case SelectMultiple: return Boolean(select.multiple()); 1471 case SelectName: return String(select.name()); 1472 case SelectSize: return Number(select.size()); 1473 case SelectTabIndex: return Number(select.tabIndex()); 1474 } 1475 } 1476 break; 1477 case ID_OPTGROUP: { 1478 HTMLOptGroupElementImpl &optgroup = static_cast<HTMLOptGroupElementImpl &>(element); 1479 switch (token) { 1480 case OptGroupDisabled: return Boolean(optgroup.disabled()); 1481 case OptGroupLabel: return String(optgroup.label()); 1482 } 1483 } 1484 break; 1485 case ID_OPTION: { 1486 HTMLOptionElementImpl &option = static_cast<HTMLOptionElementImpl &>(element); 1487 switch (token) { 1488 case OptionForm: return getDOMNode(exec,option.form()); // type HTMLFormElement 1489 case OptionDefaultSelected: return Boolean(option.defaultSelected()); 1490 case OptionText: return String(option.text()); 1491 case OptionIndex: return Number(option.index()); 1492 case OptionDisabled: return Boolean(option.disabled()); 1493 case OptionLabel: return String(option.label()); 1494 case OptionSelected: return Boolean(option.selected()); 1495 case OptionValue: return String(option.value()); 1496 } 1497 } 1498 break; 1499 case ID_INPUT: { 1500 HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element); 1501 switch (token) { 1502 case InputDefaultValue: return String(input.defaultValue()); 1503 case InputDefaultChecked: return Boolean(input.defaultChecked()); 1504 case InputForm: return getDOMNode(exec,input.form()); // type HTMLFormElement 1505 case InputAccept: return String(input.accept()); 1506 case InputAccessKey: return String(input.accessKey()); 1507 case InputAlign: return String(input.align()); 1508 case InputAlt: return String(input.alt()); 1509 case InputChecked: return Boolean(input.checked()); 1510 case InputDisabled: return Boolean(input.disabled()); 1511 case InputMaxLength: return Number(input.maxLength()); 1512 case InputName: return String(input.name()); 1513 case InputReadOnly: return Boolean(input.readOnly()); 1514 case InputSelectionStart: return getInputSelectionStart(input); 1515 case InputSelectionEnd: return getInputSelectionEnd(input); 1516 case InputSize: return String(input.sizeDOM()); 1517 case InputSrc: return String(input.src()); 1518 case InputTabIndex: return Number(input.tabIndex()); 1519 case InputType: return String(input.type()); 1520 case InputUseMap: return String(input.useMap()); 1521 case InputValue: return String(input.value()); 1522 } 1523 } 1524 break; 1525 case ID_TEXTAREA: { 1526 HTMLTextAreaElementImpl &textarea = static_cast<HTMLTextAreaElementImpl &>(element); 1527 switch (token) { 1528 case TextAreaDefaultValue: return String(textarea.defaultValue()); 1529 case TextAreaForm: return getDOMNode(exec,textarea.form()); // type HTMLFormElement 1530 case TextAreaAccessKey: return String(textarea.accessKey()); 1531 case TextAreaCols: return Number(textarea.cols()); 1532 case TextAreaDisabled: return Boolean(textarea.disabled()); 1533 case TextAreaName: return String(textarea.name()); 1534 case TextAreaReadOnly: return Boolean(textarea.readOnly()); 1535 case TextAreaRows: return Number(textarea.rows()); 1536 case TextAreaSelectionStart: return Number(textarea.selectionStart()); 1537 case TextAreaSelectionEnd: return Number(textarea.selectionEnd()); 1538 case TextAreaTabIndex: return Number(textarea.tabIndex()); 1539 case TextAreaType: return String(textarea.type()); 1540 case TextAreaValue: return String(textarea.value()); 1541 } 1542 } 1543 break; 1544 case ID_BUTTON: { 1545 HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element); 1546 switch (token) { 1547 case ButtonForm: return getDOMNode(exec,button.form()); // type HTMLFormElement 1548 case ButtonAccessKey: return String(button.accessKey()); 1549 case ButtonDisabled: return Boolean(button.disabled()); 1550 case ButtonName: return String(button.name()); 1551 case ButtonTabIndex: return Number(button.tabIndex()); 1552 case ButtonType: return String(button.type()); 1553 case ButtonValue: return String(button.value()); 1554 } 1555 } 1556 break; 1557 case ID_LABEL: { 1558 HTMLLabelElementImpl &label = static_cast<HTMLLabelElementImpl &>(element); 1559 switch (token) { 1560 case LabelForm: return getDOMNode(exec,label.form()); // type HTMLFormElement 1561 case LabelAccessKey: return String(label.accessKey()); 1562 case LabelHtmlFor: return String(label.htmlFor()); 1563 } 1564 } 1565 break; 1566 case ID_FIELDSET: { 1567 HTMLFieldSetElementImpl &fieldSet = static_cast<HTMLFieldSetElementImpl &>(element); 1568 switch (token) { 1569 case FieldSetForm: return getDOMNode(exec,fieldSet.form()); // type HTMLFormElement 1570 } 1571 } 1572 break; 1573 case ID_LEGEND: { 1574 HTMLLegendElementImpl &legend = static_cast<HTMLLegendElementImpl &>(element); 1575 switch (token) { 1576 case LegendForm: return getDOMNode(exec,legend.form()); // type HTMLFormElement 1577 case LegendAccessKey: return String(legend.accessKey()); 1578 case LegendAlign: return String(legend.align()); 1579 } 1580 } 1581 break; 1582 case ID_UL: { 1583 HTMLUListElementImpl &uList = static_cast<HTMLUListElementImpl &>(element); 1584 switch (token) { 1585 case UListCompact: return Boolean(uList.compact()); 1586 case UListType: return String(uList.type()); 1587 } 1588 } 1589 break; 1590 case ID_OL: { 1591 HTMLOListElementImpl &oList = static_cast<HTMLOListElementImpl &>(element); 1592 switch (token) { 1593 case OListCompact: return Boolean(oList.compact()); 1594 case OListStart: return Number(oList.start()); 1595 case OListType: return String(oList.type()); 1596 } 1597 } 1598 break; 1599 case ID_DL: { 1600 HTMLDListElementImpl &dList = static_cast<HTMLDListElementImpl &>(element); 1601 switch (token) { 1602 case DListCompact: return Boolean(dList.compact()); 1603 } 1604 } 1605 break; 1606 case ID_DIR: { 1607 HTMLDirectoryElementImpl &directory = static_cast<HTMLDirectoryElementImpl &>(element); 1608 switch (token) { 1609 case DirectoryCompact: return Boolean(directory.compact()); 1610 } 1611 } 1612 break; 1613 case ID_MENU: { 1614 HTMLMenuElementImpl &menu = static_cast<HTMLMenuElementImpl &>(element); 1615 switch (token) { 1616 case MenuCompact: return Boolean(menu.compact()); 1617 } 1618 } 1619 break; 1620 case ID_LI: { 1621 HTMLLIElementImpl &li = static_cast<HTMLLIElementImpl &>(element); 1622 switch (token) { 1623 case LIType: return String(li.type()); 1624 case LIValue: return Number(li.value()); 1625 } 1626 } 1627 break; 1628 case ID_DIV: { 1629 HTMLDivElementImpl &div = static_cast<HTMLDivElementImpl &>(element); 1630 switch (token) { 1631 case DivAlign: return String(div.align()); 1632 } 1633 } 1634 break; 1635 case ID_P: { 1636 HTMLParagraphElementImpl ¶graph = static_cast<HTMLParagraphElementImpl &>(element); 1637 switch (token) { 1638 case ParagraphAlign: return String(paragraph.align()); 1639 } 1640 } 1641 break; 1642 case ID_H1: 1643 case ID_H2: 1644 case ID_H3: 1645 case ID_H4: 1646 case ID_H5: 1647 case ID_H6: { 1648 HTMLHeadingElementImpl &heading = static_cast<HTMLHeadingElementImpl &>(element); 1649 switch (token) { 1650 case HeadingAlign: return String(heading.align()); 1651 } 1652 } 1653 break; 1654 case ID_BLOCKQUOTE: { 1655 HTMLBlockquoteElementImpl &blockquote = static_cast<HTMLBlockquoteElementImpl &>(element); 1656 switch (token) { 1657 case BlockQuoteCite: return String(blockquote.cite()); 1658 } 1659 } 1660 case ID_Q: { 1661 HTMLQuoteElementImpl "e = static_cast<HTMLQuoteElementImpl &>(element); 1662 switch (token) { 1663 case QuoteCite: return String(quote.cite()); 1664 } 1665 } 1666 case ID_PRE: { 1667 HTMLPreElementImpl &pre = static_cast<HTMLPreElementImpl &>(element); 1668 switch (token) { 1669 case PreWidth: return Number(pre.width()); 1670 } 1671 } 1672 break; 1673 case ID_BR: { 1674 HTMLBRElementImpl &br = static_cast<HTMLBRElementImpl &>(element); 1675 switch (token) { 1676 case BRClear: return String(br.clear()); 1677 } 1678 } 1679 break; 1680 case ID_BASEFONT: { 1681 HTMLBaseFontElementImpl &baseFont = static_cast<HTMLBaseFontElementImpl &>(element); 1682 switch (token) { 1683 case BaseFontColor: return String(baseFont.color()); 1684 case BaseFontFace: return String(baseFont.face()); 1685 case BaseFontSize: return String(baseFont.size()); 1686 } 1687 } 1688 break; 1689 case ID_FONT: { 1690 HTMLFontElementImpl &font = static_cast<HTMLFontElementImpl &>(element); 1691 switch (token) { 1692 case FontColor: return String(font.color()); 1693 case FontFace: return String(font.face()); 1694 case FontSize: return String(font.size()); 1695 } 1696 } 1697 break; 1698 case ID_HR: { 1699 HTMLHRElementImpl &hr = static_cast<HTMLHRElementImpl &>(element); 1700 switch (token) { 1701 case HRAlign: return String(hr.align()); 1702 case HRNoShade: return Boolean(hr.noShade()); 1703 case HRSize: return String(hr.size()); 1704 case HRWidth: return String(hr.width()); 1705 } 1706 } 1707 break; 1708 case ID_INS: 1709 case ID_DEL: { 1710 HTMLModElementImpl &mod = static_cast<HTMLModElementImpl &>(element); 1711 switch (token) { 1712 case ModCite: return String(mod.cite()); 1713 case ModDateTime: return String(mod.dateTime()); 1714 } 1715 } 1716 break; 1717 case ID_A: { 1718 HTMLAnchorElementImpl &anchor = static_cast<HTMLAnchorElementImpl &>(element); 1719 switch (token) { 1720 case AnchorAccessKey: return String(anchor.accessKey()); 1721 case AnchorCharset: return String(anchor.charset()); 1722 case AnchorCoords: return String(anchor.coords()); 1723 case AnchorHref: return String(anchor.href()); 1724 case AnchorHrefLang: return String(anchor.hreflang()); 1725 case AnchorHash: return String('#'+KURL(anchor.href().string()).ref()); 1726 case AnchorHost: return String(KURL(anchor.href().string()).host()); 1727 case AnchorHostname: { 1728 KURL url(anchor.href().string()); 1729 kdDebug(6070) << "anchor::hostname uses:" <<url.url()<<endl; 1730 if (url.port()==0) 1731 return String(url.host()); 1732 else 1733 return String(url.host() + ":" + QString::number(url.port())); 1734 } 1735 case AnchorPathName: return String(KURL(anchor.href().string()).path()); 1736 case AnchorPort: return String(QString::number(KURL(anchor.href().string()).port())); 1737 case AnchorProtocol: return String(KURL(anchor.href().string()).protocol()+":"); 1738 case AnchorSearch: return String(KURL(anchor.href().string()).query()); 1739 case AnchorName: return String(anchor.name()); 1740 case AnchorRel: return String(anchor.rel()); 1741 case AnchorRev: return String(anchor.rev()); 1742 case AnchorShape: return String(anchor.shape()); 1743 case AnchorTabIndex: return Number(anchor.tabIndex()); 1744 case AnchorTarget: return String(anchor.target()); 1745 case AnchorType: return String(anchor.type()); 1746 case AnchorText: 1747 if (DocumentImpl* doc = anchor.getDocument()) 1748 doc->updateLayoutIgnorePendingStylesheets(); 1749 return String(anchor.innerText()); 1750 } 1751 } 1752 break; 1753 case ID_IMG: { 1754 HTMLImageElementImpl &image = static_cast<HTMLImageElementImpl &>(element); 1755 switch (token) { 1756 case ImageName: return String(image.name()); 1757 case ImageAlign: return String(image.align()); 1758 case ImageAlt: return String(image.alt()); 1759 case ImageBorder: return Number(image.border()); 1760 case ImageHeight: return Number(image.height(true)); 1761 case ImageHspace: return Number(image.hspace()); 1762 case ImageIsMap: return Boolean(image.isMap()); 1763 case ImageLongDesc: return String(image.longDesc()); 1764 case ImageSrc: return String(image.src()); 1765 case ImageUseMap: return String(image.useMap()); 1766 case ImageVspace: return Number(image.vspace()); 1767 case ImageWidth: return Number(image.width(true)); 1768 case ImageX: return Number(image.x()); 1769 case ImageY: return Number(image.y()); 1770 } 1771 } 1772 break; 1773 case ID_OBJECT: { 1774 HTMLObjectElementImpl &object = static_cast<HTMLObjectElementImpl &>(element); 1775 switch (token) { 1776 case ObjectForm: return getDOMNode(exec,object.form()); // type HTMLFormElement 1777 case ObjectCode: return String(object.code()); 1778 case ObjectAlign: return String(object.align()); 1779 case ObjectArchive: return String(object.archive()); 1780 case ObjectBorder: return String(object.border()); 1781 case ObjectCodeBase: return String(object.codeBase()); 1782 case ObjectCodeType: return String(object.codeType()); 1783 case ObjectContentDocument: return checkNodeSecurity(exec,object.contentDocument()) ? 1784 getDOMNode(exec, object.contentDocument()) : Undefined(); 1785 case ObjectData: return String(object.data()); 1786 case ObjectDeclare: return Boolean(object.declare()); 1787 case ObjectHeight: return String(object.height()); 1788 case ObjectHspace: return String(object.hspace()); 1789 case ObjectName: return String(object.name()); 1790 case ObjectStandby: return String(object.standby()); 1791 case ObjectTabIndex: return Number(object.tabIndex()); 1792 case ObjectType: return String(object.type()); 1793 case ObjectUseMap: return String(object.useMap()); 1794 case ObjectVspace: return String(object.vspace()); 1795 case ObjectWidth: return String(object.width()); 1796 } 1797 } 1798 break; 1799 case ID_PARAM: { 1800 HTMLParamElementImpl ¶m = static_cast<HTMLParamElementImpl &>(element); 1801 switch (token) { 1802 case ParamName: return String(param.name()); 1803 case ParamType: return String(param.type()); 1804 case ParamValue: return String(param.value()); 1805 case ParamValueType: return String(param.valueType()); 1806 } 1807 } 1808 break; 1809 case ID_APPLET: { 1810 HTMLAppletElementImpl &applet = static_cast<HTMLAppletElementImpl &>(element); 1811 switch (token) { 1812 case AppletAlign: return String(applet.align()); 1813 case AppletAlt: return String(applet.alt()); 1814 case AppletArchive: return String(applet.archive()); 1815 case AppletCode: return String(applet.code()); 1816 case AppletCodeBase: return String(applet.codeBase()); 1817 case AppletHeight: return String(applet.height()); 1818 case AppletHspace: return String(applet.hspace()); 1819 case AppletName: return String(applet.name()); 1820 case AppletObject: return String(applet.object()); 1821 case AppletVspace: return String(applet.vspace()); 1822 case AppletWidth: return String(applet.width()); 1823 } 1824 } 1825 break; 1826 case ID_MAP: { 1827 HTMLMapElementImpl &map = static_cast<HTMLMapElementImpl &>(element); 1828 switch (token) { 1829 case MapAreas: return getHTMLCollection(exec, map.areas().get()); // type HTMLCollection 1830 case MapName: return String(map.name()); 1831 } 1832 } 1833 break; 1834 case ID_AREA: { 1835 HTMLAreaElementImpl &area = static_cast<HTMLAreaElementImpl &>(element); 1836 switch (token) { 1837 case AreaAccessKey: return String(area.accessKey()); 1838 case AreaAlt: return String(area.alt()); 1839 case AreaCoords: return String(area.coords()); 1840 case AreaHref: return String(area.href()); 1841 case AreaHash: return String('#'+KURL(area.href().string()).ref()); 1842 case AreaHost: return String(KURL(area.href().string()).host()); 1843 case AreaHostName: { 1844 KURL url(area.href().string()); 1845 kdDebug(6070) << "link::hostname uses:" <<url.url()<<endl; 1846 if (url.port()==0) 1847 return String(url.host()); 1848 else 1849 return String(url.host() + ":" + QString::number(url.port())); 1850 } 1851 case AreaPathName: return String(KURL(area.href().string()).path()); 1852 case AreaPort: return String(QString::number(KURL(area.href().string()).port())); 1853 case AreaProtocol: return String(KURL(area.href().string()).protocol()+":"); 1854 case AreaSearch: return String(KURL(area.href().string()).query()); 1855 case AreaNoHref: return Boolean(area.noHref()); 1856 case AreaShape: return String(area.shape()); 1857 case AreaTabIndex: return Number(area.tabIndex()); 1858 case AreaTarget: return String(area.target()); 1859 } 1860 } 1861 break; 1862 case ID_SCRIPT: { 1863 HTMLScriptElementImpl &script = static_cast<HTMLScriptElementImpl &>(element); 1864 switch (token) { 1865 case ScriptText: return String(script.text()); 1866 case ScriptHtmlFor: return String(script.htmlFor()); 1867 case ScriptEvent: return String(script.event()); 1868 case ScriptCharset: return String(script.charset()); 1869 case ScriptDefer: return Boolean(script.defer()); 1870 case ScriptSrc: return String(script.src()); 1871 case ScriptType: return String(script.type()); 1872 } 1873 } 1874 break; 1875 case ID_TABLE: { 1876 HTMLTableElementImpl &table = static_cast<HTMLTableElementImpl &>(element); 1877 switch (token) { 1878 case TableCaption: return getDOMNode(exec,table.caption()); // type HTMLTableCaptionElement 1879 case TableTHead: return getDOMNode(exec,table.tHead()); // type HTMLTableSectionElement 1880 case TableTFoot: return getDOMNode(exec,table.tFoot()); // type HTMLTableSectionElement 1881 case TableRows: return getHTMLCollection(exec, table.rows().get()); // type HTMLCollection 1882 case TableTBodies: return getHTMLCollection(exec, table.tBodies().get()); // type HTMLCollection 1883 case TableAlign: return String(table.align()); 1884 case TableBgColor: return String(table.bgColor()); 1885 case TableBorder: return String(table.border()); 1886 case TableCellPadding: return String(table.cellPadding()); 1887 case TableCellSpacing: return String(table.cellSpacing()); 1888 case TableFrame: return String(table.frame()); 1889 case TableRules: return String(table.rules()); 1890 case TableSummary: return String(table.summary()); 1891 case TableWidth: return String(table.width()); 1892 } 1893 } 1894 break; 1895 case ID_CAPTION: { 1896 HTMLTableCaptionElementImpl &tableCaption = static_cast<HTMLTableCaptionElementImpl &>(element); 1897 switch (token) { 1898 case TableCaptionAlign: return String(tableCaption.align()); 1899 } 1900 } 1901 break; 1902 case ID_COL: { 1903 HTMLTableColElementImpl &tableCol = static_cast<HTMLTableColElementImpl &>(element); 1904 switch (token) { 1905 case TableColAlign: return String(tableCol.align()); 1906 case TableColCh: return String(tableCol.ch()); 1907 case TableColChOff: return String(tableCol.chOff()); 1908 case TableColSpan: return Number(tableCol.span()); 1909 case TableColVAlign: return String(tableCol.vAlign()); 1910 case TableColWidth: return String(tableCol.width()); 1911 } 1912 } 1913 break; 1914 case ID_THEAD: 1915 case ID_TBODY: 1916 case ID_TFOOT: { 1917 HTMLTableSectionElementImpl &tableSection = static_cast<HTMLTableSectionElementImpl &>(element); 1918 switch (token) { 1919 case TableSectionAlign: return String(tableSection.align()); 1920 case TableSectionCh: return String(tableSection.ch()); 1921 case TableSectionChOff: return String(tableSection.chOff()); 1922 case TableSectionVAlign: return String(tableSection.vAlign()); 1923 case TableSectionRows: return getHTMLCollection(exec, tableSection.rows().get()); // type HTMLCollection 1924 } 1925 } 1926 break; 1927 case ID_TR: { 1928 HTMLTableRowElementImpl &tableRow = static_cast<HTMLTableRowElementImpl &>(element); 1929 switch (token) { 1930 case TableRowRowIndex: return Number(tableRow.rowIndex()); 1931 case TableRowSectionRowIndex: return Number(tableRow.sectionRowIndex()); 1932 case TableRowCells: return getHTMLCollection(exec, tableRow.cells().get()); // type HTMLCollection 1933 case TableRowAlign: return String(tableRow.align()); 1934 case TableRowBgColor: return String(tableRow.bgColor()); 1935 case TableRowCh: return String(tableRow.ch()); 1936 case TableRowChOff: return String(tableRow.chOff()); 1937 case TableRowVAlign: return String(tableRow.vAlign()); 1938 } 1939 } 1940 break; 1941 case ID_TH: 1942 case ID_TD: { 1943 HTMLTableCellElementImpl &tableCell = static_cast<HTMLTableCellElementImpl &>(element); 1944 switch (token) { 1945 case TableCellCellIndex: return Number(tableCell.cellIndex()); 1946 case TableCellAbbr: return String(tableCell.abbr()); 1947 case TableCellAlign: return String(tableCell.align()); 1948 case TableCellAxis: return String(tableCell.axis()); 1949 case TableCellBgColor: return String(tableCell.bgColor()); 1950 case TableCellCh: return String(tableCell.ch()); 1951 case TableCellChOff: return String(tableCell.chOff()); 1952 case TableCellColSpan: return Number(tableCell.colSpan()); 1953 case TableCellHeaders: return String(tableCell.headers()); 1954 case TableCellHeight: return String(tableCell.height()); 1955 case TableCellNoWrap: return Boolean(tableCell.noWrap()); 1956 case TableCellRowSpan: return Number(tableCell.rowSpan()); 1957 case TableCellScope: return String(tableCell.scope()); 1958 case TableCellVAlign: return String(tableCell.vAlign()); 1959 case TableCellWidth: return String(tableCell.width()); 1960 } 1961 } 1962 break; 1963 case ID_FRAMESET: { 1964 HTMLFrameSetElementImpl &frameSet = static_cast<HTMLFrameSetElementImpl &>(element); 1965 switch (token) { 1966 case FrameSetCols: return String(frameSet.cols()); 1967 case FrameSetRows: return String(frameSet.rows()); 1968 } 1969 } 1970 break; 1971 case ID_FRAME: { 1972 HTMLFrameElementImpl &frameElement = static_cast<HTMLFrameElementImpl &>(element); 1973 switch (token) { 1974 case FrameContentDocument: return checkNodeSecurity(exec,frameElement.contentDocument()) ? 1975 getDOMNode(exec, frameElement.contentDocument()) : Undefined(); 1976 case FrameContentWindow: return checkNodeSecurity(exec,frameElement.contentDocument()) 1977 ? Window::retrieve(frameElement.contentPart()) 1978 : Undefined(); 1979 case FrameFrameBorder: return String(frameElement.frameBorder()); 1980 case FrameLongDesc: return String(frameElement.longDesc()); 1981 case FrameMarginHeight: return String(frameElement.marginHeight()); 1982 case FrameMarginWidth: return String(frameElement.marginWidth()); 1983 case FrameName: return String(frameElement.name()); 1984 case FrameNoResize: return Boolean(frameElement.noResize()); 1985 case FrameScrolling: return String(frameElement.scrolling()); 1986 case FrameSrc: 1987 case FrameLocation: return String(frameElement.src()); 1988 } 1989 } 1990 break; 1991 case ID_IFRAME: { 1992 HTMLIFrameElementImpl &iFrame = static_cast<HTMLIFrameElementImpl &>(element); 1993 switch (token) { 1994 case IFrameAlign: return String(iFrame.align()); 1995 // ### security check ? 1996 case IFrameDocument: // non-standard, mapped to contentDocument 1997 case IFrameContentDocument: return checkNodeSecurity(exec,iFrame.contentDocument()) ? 1998 getDOMNode(exec, iFrame.contentDocument()) : Undefined(); 1999 case IFrameContentWindow: return checkNodeSecurity(exec,iFrame.contentDocument()) 2000 ? Window::retrieve(iFrame.contentPart()) 2001 : Undefined(); 2002 case IFrameFrameBorder: return String(iFrame.frameBorder()); 2003 case IFrameHeight: return String(iFrame.height()); 2004 case IFrameLongDesc: return String(iFrame.longDesc()); 2005 case IFrameMarginHeight: return String(iFrame.marginHeight()); 2006 case IFrameMarginWidth: return String(iFrame.marginWidth()); 2007 case IFrameName: return String(iFrame.name()); 2008 case IFrameScrolling: return String(iFrame.scrolling()); 2009 case IFrameSrc: return String(iFrame.src()); 2010 case IFrameWidth: return String(iFrame.width()); 2011 } 2012 break; 2013 } 2014 } // xemacs (or arnt) could be a bit smarter when it comes to indenting switch()es ;) 2015 // its not arnt to blame - its the original Stroustrup style we like :) (Dirk) 2016 2017 // generic properties 2018 switch (token) { 2019 case ElementId: 2020 // iht.com relies on this value being "" when no id is present. Other browsers do this as well. 2021 // So we use String() instead of String() here. 2022 return String(element.idDOM()); 2023 case ElementTitle: 2024 return String(element.title()); 2025 case ElementLang: 2026 return String(element.lang()); 2027 case ElementDir: 2028 return String(element.dir()); 2029 case ElementClassName: 2030 return String(element.className()); 2031 case ElementInnerHTML: 2032 return String(element.innerHTML()); 2033 case ElementInnerText: 2034 if (DocumentImpl* doc = impl()->getDocument()) 2035 doc->updateLayoutIgnorePendingStylesheets(); 2036 return String(element.innerText()); 2037 case ElementOuterHTML: 2038 return String(element.outerHTML()); 2039 case ElementOuterText: 2040 return String(element.outerText()); 2041 case ElementDocument: 2042 return getDOMNode(exec,element.ownerDocument()); 2043 case ElementChildren: 2044 return getHTMLCollection(exec, element.children().get()); 2045 case ElementContentEditable: 2046 return String(element.contentEditable()); 2047 case ElementIsContentEditable: 2048 return Boolean(element.isContentEditable()); 2049 // ### what about style? or is this used instead for DOM2 stylesheets? 2050 } 2051 kdWarning() << "HTMLElement::getValueProperty unhandled token " << token << endl; 2052 return Undefined(); 1587 if (input.canHaveSelection()) 1588 return Number(input.selectionEnd()); 1589 return Undefined(); 1590 } 1591 1592 Value HTMLElement::inputGetter(ExecState* exec, int token) const 1593 { 1594 HTMLInputElementImpl& input = *static_cast<HTMLInputElementImpl*>(impl()); 1595 switch (token) { 1596 case InputDefaultValue: return String(input.defaultValue()); 1597 case InputDefaultChecked: return Boolean(input.defaultChecked()); 1598 case InputForm: return getDOMNode(exec,input.form()); // type HTMLFormElement 1599 case InputAccept: return String(input.accept()); 1600 case InputAccessKey: return String(input.accessKey()); 1601 case InputAlign: return String(input.align()); 1602 case InputAlt: return String(input.alt()); 1603 case InputChecked: return Boolean(input.checked()); 1604 case InputDisabled: return Boolean(input.disabled()); 1605 case InputMaxLength: return Number(input.maxLength()); 1606 case InputName: return String(input.name()); 1607 case InputReadOnly: return Boolean(input.readOnly()); 1608 case InputSelectionStart: return getInputSelectionStart(input); 1609 case InputSelectionEnd: return getInputSelectionEnd(input); 1610 case InputSize: return String(input.sizeDOM()); 1611 case InputSrc: return String(input.src()); 1612 case InputTabIndex: return Number(input.tabIndex()); 1613 case InputType: return String(input.type()); 1614 case InputUseMap: return String(input.useMap()); 1615 case InputValue: return String(input.value()); 1616 } 1617 return Undefined(); 1618 } 1619 1620 Value HTMLElement::textAreaGetter(ExecState* exec, int token) const 1621 { 1622 HTMLTextAreaElementImpl& textarea = *static_cast<HTMLTextAreaElementImpl*>(impl()); 1623 switch (token) { 1624 case TextAreaDefaultValue: return String(textarea.defaultValue()); 1625 case TextAreaForm: return getDOMNode(exec,textarea.form()); // type HTMLFormElement 1626 case TextAreaAccessKey: return String(textarea.accessKey()); 1627 case TextAreaCols: return Number(textarea.cols()); 1628 case TextAreaDisabled: return Boolean(textarea.disabled()); 1629 case TextAreaName: return String(textarea.name()); 1630 case TextAreaReadOnly: return Boolean(textarea.readOnly()); 1631 case TextAreaRows: return Number(textarea.rows()); 1632 case TextAreaSelectionStart: return Number(textarea.selectionStart()); 1633 case TextAreaSelectionEnd: return Number(textarea.selectionEnd()); 1634 case TextAreaTabIndex: return Number(textarea.tabIndex()); 1635 case TextAreaType: return String(textarea.type()); 1636 case TextAreaValue: return String(textarea.value()); 1637 } 1638 return Undefined(); 1639 } 1640 1641 Value HTMLElement::buttonGetter(ExecState* exec, int token) const 1642 { 1643 HTMLButtonElementImpl& button = *static_cast<HTMLButtonElementImpl*>(impl()); 1644 switch (token) { 1645 case ButtonForm: return getDOMNode(exec,button.form()); // type HTMLFormElement 1646 case ButtonAccessKey: return String(button.accessKey()); 1647 case ButtonDisabled: return Boolean(button.disabled()); 1648 case ButtonName: return String(button.name()); 1649 case ButtonTabIndex: return Number(button.tabIndex()); 1650 case ButtonType: return String(button.type()); 1651 case ButtonValue: return String(button.value()); 1652 } 1653 return Undefined(); 1654 } 1655 1656 Value HTMLElement::labelGetter(ExecState* exec, int token) const 1657 { 1658 HTMLLabelElementImpl& label = *static_cast<HTMLLabelElementImpl*>(impl()); 1659 switch (token) { 1660 case LabelForm: return getDOMNode(exec,label.form()); // type HTMLFormElement 1661 case LabelAccessKey: return String(label.accessKey()); 1662 case LabelHtmlFor: return String(label.htmlFor()); 1663 } 1664 return Undefined(); 1665 } 1666 1667 Value HTMLElement::fieldSetGetter(ExecState* exec, int token) const 1668 { 1669 HTMLFieldSetElementImpl& fieldSet = *static_cast<HTMLFieldSetElementImpl*>(impl()); 1670 if (token == FieldSetForm) 1671 return getDOMNode(exec,fieldSet.form()); // type HTMLFormElement 1672 return Undefined(); 1673 } 1674 1675 Value HTMLElement::legendGetter(ExecState* exec, int token) const 1676 { 1677 HTMLLegendElementImpl& legend = *static_cast<HTMLLegendElementImpl*>(impl()); 1678 switch (token) { 1679 case LegendForm: return getDOMNode(exec,legend.form()); // type HTMLFormElement 1680 case LegendAccessKey: return String(legend.accessKey()); 1681 case LegendAlign: return String(legend.align()); 1682 } 1683 return Undefined(); 1684 } 1685 1686 Value HTMLElement::uListGetter(ExecState* exec, int token) const 1687 { 1688 HTMLUListElementImpl& uList = *static_cast<HTMLUListElementImpl*>(impl()); 1689 switch (token) { 1690 case UListCompact: return Boolean(uList.compact()); 1691 case UListType: return String(uList.type()); 1692 } 1693 return Undefined(); 1694 } 1695 1696 Value HTMLElement::oListGetter(ExecState* exec, int token) const 1697 { 1698 HTMLOListElementImpl& oList = *static_cast<HTMLOListElementImpl*>(impl()); 1699 switch (token) { 1700 case OListCompact: return Boolean(oList.compact()); 1701 case OListStart: return Number(oList.start()); 1702 case OListType: return String(oList.type()); 1703 } 1704 return Undefined(); 1705 } 1706 1707 Value HTMLElement::dListGetter(ExecState* exec, int token) const 1708 { 1709 HTMLDListElementImpl& dList = *static_cast<HTMLDListElementImpl*>(impl()); 1710 if (token == DListCompact) 1711 return Boolean(dList.compact()); 1712 return Undefined(); 1713 } 1714 1715 Value HTMLElement::dirGetter(ExecState* exec, int token) const 1716 { 1717 HTMLDirectoryElementImpl& dir = *static_cast<HTMLDirectoryElementImpl*>(impl()); 1718 if (token == DirectoryCompact) 1719 return Boolean(dir.compact()); 1720 return Undefined(); 1721 } 1722 1723 Value HTMLElement::menuGetter(ExecState* exec, int token) const 1724 { 1725 HTMLMenuElementImpl& menu = *static_cast<HTMLMenuElementImpl*>(impl()); 1726 if (token == MenuCompact) 1727 return Boolean(menu.compact()); 1728 return Undefined(); 1729 } 1730 1731 Value HTMLElement::liGetter(ExecState* exec, int token) const 1732 { 1733 HTMLLIElementImpl& li = *static_cast<HTMLLIElementImpl*>(impl()); 1734 switch (token) { 1735 case LIType: return String(li.type()); 1736 case LIValue: return Number(li.value()); 1737 } 1738 return Undefined(); 1739 } 1740 1741 Value HTMLElement::divGetter(ExecState* exec, int token) const 1742 { 1743 HTMLDivElementImpl& div = *static_cast<HTMLDivElementImpl*>(impl()); 1744 if (token == DivAlign) 1745 return String(div.align()); 1746 return Undefined(); 1747 } 1748 1749 Value HTMLElement::paragraphGetter(ExecState* exec, int token) const 1750 { 1751 HTMLParagraphElementImpl& p = *static_cast<HTMLParagraphElementImpl*>(impl()); 1752 if (token == ParagraphAlign) 1753 return String(p.align()); 1754 return Undefined(); 1755 } 1756 1757 Value HTMLElement::headingGetter(ExecState* exec, int token) const 1758 { 1759 HTMLHeadingElementImpl& h = *static_cast<HTMLHeadingElementImpl*>(impl()); 1760 if (token == HeadingAlign) 1761 return String(h.align()); 1762 return Undefined(); 1763 } 1764 1765 Value HTMLElement::blockQuoteGetter(ExecState* exec, int token) const 1766 { 1767 HTMLBlockquoteElementImpl& blockQuote = *static_cast<HTMLBlockquoteElementImpl*>(impl()); 1768 if (token == BlockQuoteCite) 1769 return String(blockQuote.cite()); 1770 return Undefined(); 1771 } 1772 1773 Value HTMLElement::quoteGetter(ExecState* exec, int token) const 1774 { 1775 HTMLQuoteElementImpl& quote = *static_cast<HTMLQuoteElementImpl*>(impl()); 1776 if (token == QuoteCite) 1777 return String(quote.cite()); 1778 return Undefined(); 1779 } 1780 1781 Value HTMLElement::preGetter(ExecState* exec, int token) const 1782 { 1783 // FIXME: Add support for 'wrap' when white-space: pre-wrap is implemented. 1784 HTMLPreElementImpl& pre = *static_cast<HTMLPreElementImpl*>(impl()); 1785 if (token == PreWidth) 1786 return Number(pre.width()); 1787 return Undefined(); 1788 } 1789 1790 Value HTMLElement::brGetter(ExecState* exec, int token) const 1791 { 1792 HTMLBRElementImpl& br = *static_cast<HTMLBRElementImpl*>(impl()); 1793 if (token == BRClear) 1794 return String(br.clear()); 1795 return Undefined(); 1796 } 1797 1798 Value HTMLElement::baseFontGetter(ExecState* exec, int token) const 1799 { 1800 HTMLBaseFontElementImpl& baseFont = *static_cast<HTMLBaseFontElementImpl*>(impl()); 1801 switch (token) { 1802 case BaseFontColor: return String(baseFont.color()); 1803 case BaseFontFace: return String(baseFont.face()); 1804 case BaseFontSize: return String(baseFont.size()); 1805 } 1806 return Undefined(); 1807 } 1808 1809 Value HTMLElement::fontGetter(ExecState* exec, int token) const 1810 { 1811 HTMLFontElementImpl& font = *static_cast<HTMLFontElementImpl*>(impl()); 1812 switch (token) { 1813 case FontColor: return String(font.color()); 1814 case FontFace: return String(font.face()); 1815 case FontSize: return String(font.size()); 1816 } 1817 return Undefined(); 1818 } 1819 1820 Value HTMLElement::hrGetter(ExecState* exec, int token) const 1821 { 1822 HTMLHRElementImpl& hr = *static_cast<HTMLHRElementImpl*>(impl()); 1823 switch (token) { 1824 case HRAlign: return String(hr.align()); 1825 case HRNoShade: return Boolean(hr.noShade()); 1826 case HRSize: return String(hr.size()); 1827 case HRWidth: return String(hr.width()); 1828 } 1829 return Undefined(); 1830 } 1831 1832 Value HTMLElement::modGetter(ExecState* exec, int token) const 1833 { 1834 HTMLModElementImpl& mod = *static_cast<HTMLModElementImpl*>(impl()); 1835 switch (token) { 1836 case ModCite: return String(mod.cite()); 1837 case ModDateTime: return String(mod.dateTime()); 1838 } 1839 return Undefined(); 1840 } 1841 1842 Value HTMLElement::anchorGetter(ExecState* exec, int token) const 1843 { 1844 HTMLAnchorElementImpl& anchor = *static_cast<HTMLAnchorElementImpl*>(impl()); 1845 switch (token) { 1846 case AnchorAccessKey: return String(anchor.accessKey()); 1847 case AnchorCharset: return String(anchor.charset()); 1848 case AnchorCoords: return String(anchor.coords()); 1849 case AnchorHref: return String(anchor.href()); 1850 case AnchorHrefLang: return String(anchor.hreflang()); 1851 case AnchorHash: return String('#'+KURL(anchor.href().string()).ref()); 1852 case AnchorHost: return String(KURL(anchor.href().string()).host()); 1853 case AnchorHostname: { 1854 KURL url(anchor.href().string()); 1855 kdDebug(6070) << "anchor::hostname uses:" <<url.url()<<endl; 1856 if (url.port()==0) 1857 return String(url.host()); 1858 else 1859 return String(url.host() + ":" + QString::number(url.port())); 1860 } 1861 case AnchorPathName: return String(KURL(anchor.href().string()).path()); 1862 case AnchorPort: return String(QString::number(KURL(anchor.href().string()).port())); 1863 case AnchorProtocol: return String(KURL(anchor.href().string()).protocol()+":"); 1864 case AnchorSearch: return String(KURL(anchor.href().string()).query()); 1865 case AnchorName: return String(anchor.name()); 1866 case AnchorRel: return String(anchor.rel()); 1867 case AnchorRev: return String(anchor.rev()); 1868 case AnchorShape: return String(anchor.shape()); 1869 case AnchorTabIndex: return Number(anchor.tabIndex()); 1870 case AnchorTarget: return String(anchor.target()); 1871 case AnchorType: return String(anchor.type()); 1872 case AnchorText: 1873 if (DocumentImpl* doc = anchor.getDocument()) 1874 doc->updateLayoutIgnorePendingStylesheets(); 1875 return String(anchor.innerText()); 1876 } 1877 return Undefined(); 1878 } 1879 1880 Value HTMLElement::imageGetter(ExecState* exec, int token) const 1881 { 1882 HTMLImageElementImpl& image = *static_cast<HTMLImageElementImpl*>(impl()); 1883 switch (token) { 1884 case ImageName: return String(image.name()); 1885 case ImageAlign: return String(image.align()); 1886 case ImageAlt: return String(image.alt()); 1887 case ImageBorder: return Number(image.border()); 1888 case ImageHeight: return Number(image.height(true)); 1889 case ImageHspace: return Number(image.hspace()); 1890 case ImageIsMap: return Boolean(image.isMap()); 1891 case ImageLongDesc: return String(image.longDesc()); 1892 case ImageSrc: return String(image.src()); 1893 case ImageUseMap: return String(image.useMap()); 1894 case ImageVspace: return Number(image.vspace()); 1895 case ImageWidth: return Number(image.width(true)); 1896 case ImageX: return Number(image.x()); 1897 case ImageY: return Number(image.y()); 1898 } 1899 return Undefined(); 1900 } 1901 1902 Value HTMLElement::objectGetter(ExecState* exec, int token) const 1903 { 1904 HTMLObjectElementImpl& object = *static_cast<HTMLObjectElementImpl*>(impl()); 1905 switch (token) { 1906 case ObjectForm: return getDOMNode(exec,object.form()); // type HTMLFormElement 1907 case ObjectCode: return String(object.code()); 1908 case ObjectAlign: return String(object.align()); 1909 case ObjectArchive: return String(object.archive()); 1910 case ObjectBorder: return String(object.border()); 1911 case ObjectCodeBase: return String(object.codeBase()); 1912 case ObjectCodeType: return String(object.codeType()); 1913 case ObjectContentDocument: return checkNodeSecurity(exec,object.contentDocument()) ? 1914 getDOMNode(exec, object.contentDocument()) : Undefined(); 1915 case ObjectData: return String(object.data()); 1916 case ObjectDeclare: return Boolean(object.declare()); 1917 case ObjectHeight: return String(object.height()); 1918 case ObjectHspace: return String(object.hspace()); 1919 case ObjectName: return String(object.name()); 1920 case ObjectStandby: return String(object.standby()); 1921 case ObjectTabIndex: return Number(object.tabIndex()); 1922 case ObjectType: return String(object.type()); 1923 case ObjectUseMap: return String(object.useMap()); 1924 case ObjectVspace: return String(object.vspace()); 1925 case ObjectWidth: return String(object.width()); 1926 } 1927 return Undefined(); 1928 } 1929 1930 Value HTMLElement::paramGetter(ExecState* exec, int token) const 1931 { 1932 HTMLParamElementImpl& param = *static_cast<HTMLParamElementImpl*>(impl()); 1933 switch (token) { 1934 case ParamName: return String(param.name()); 1935 case ParamType: return String(param.type()); 1936 case ParamValue: return String(param.value()); 1937 case ParamValueType: return String(param.valueType()); 1938 } 1939 return Undefined(); 1940 } 1941 1942 Value HTMLElement::appletGetter(ExecState* exec, int token) const 1943 { 1944 HTMLAppletElementImpl& applet = *static_cast<HTMLAppletElementImpl*>(impl()); 1945 switch (token) { 1946 case AppletAlign: return String(applet.align()); 1947 case AppletAlt: return String(applet.alt()); 1948 case AppletArchive: return String(applet.archive()); 1949 case AppletCode: return String(applet.code()); 1950 case AppletCodeBase: return String(applet.codeBase()); 1951 case AppletHeight: return String(applet.height()); 1952 case AppletHspace: return String(applet.hspace()); 1953 case AppletName: return String(applet.name()); 1954 case AppletObject: return String(applet.object()); 1955 case AppletVspace: return String(applet.vspace()); 1956 case AppletWidth: return String(applet.width()); 1957 } 1958 return Undefined(); 1959 } 1960 1961 Value HTMLElement::mapGetter(ExecState* exec, int token) const 1962 { 1963 HTMLMapElementImpl& map = *static_cast<HTMLMapElementImpl*>(impl()); 1964 switch (token) { 1965 case MapAreas: return getHTMLCollection(exec, map.areas().get()); // type HTMLCollection 1966 case MapName: return String(map.name()); 1967 } 1968 return Undefined(); 1969 } 1970 1971 Value HTMLElement::areaGetter(ExecState* exec, int token) const 1972 { 1973 HTMLAreaElementImpl& area = *static_cast<HTMLAreaElementImpl*>(impl()); 1974 switch (token) { 1975 case AreaAccessKey: return String(area.accessKey()); 1976 case AreaAlt: return String(area.alt()); 1977 case AreaCoords: return String(area.coords()); 1978 case AreaHref: return String(area.href()); 1979 case AreaHash: return String('#'+KURL(area.href().string()).ref()); 1980 case AreaHost: return String(KURL(area.href().string()).host()); 1981 case AreaHostName: { 1982 KURL url(area.href().string()); 1983 kdDebug(6070) << "link::hostname uses:" <<url.url()<<endl; 1984 if (url.port()==0) 1985 return String(url.host()); 1986 else 1987 return String(url.host() + ":" + QString::number(url.port())); 1988 } 1989 case AreaPathName: return String(KURL(area.href().string()).path()); 1990 case AreaPort: return String(QString::number(KURL(area.href().string()).port())); 1991 case AreaProtocol: return String(KURL(area.href().string()).protocol()+":"); 1992 case AreaSearch: return String(KURL(area.href().string()).query()); 1993 case AreaNoHref: return Boolean(area.noHref()); 1994 case AreaShape: return String(area.shape()); 1995 case AreaTabIndex: return Number(area.tabIndex()); 1996 case AreaTarget: return String(area.target()); 1997 } 1998 return Undefined(); 1999 } 2000 2001 Value HTMLElement::scriptGetter(ExecState* exec, int token) const 2002 { 2003 HTMLScriptElementImpl& script = *static_cast<HTMLScriptElementImpl*>(impl()); 2004 switch (token) { 2005 case ScriptText: return String(script.text()); 2006 case ScriptHtmlFor: return String(script.htmlFor()); 2007 case ScriptEvent: return String(script.event()); 2008 case ScriptCharset: return String(script.charset()); 2009 case ScriptDefer: return Boolean(script.defer()); 2010 case ScriptSrc: return String(script.src()); 2011 case ScriptType: return String(script.type()); 2012 } 2013 return Undefined(); 2014 } 2015 2016 Value HTMLElement::tableGetter(ExecState* exec, int token) const 2017 { 2018 HTMLTableElementImpl& table = *static_cast<HTMLTableElementImpl*>(impl()); 2019 switch (token) { 2020 case TableCaption: return getDOMNode(exec,table.caption()); // type HTMLTableCaptionElement 2021 case TableTHead: return getDOMNode(exec,table.tHead()); // type HTMLTableSectionElement 2022 case TableTFoot: return getDOMNode(exec,table.tFoot()); // type HTMLTableSectionElement 2023 case TableRows: return getHTMLCollection(exec, table.rows().get()); // type HTMLCollection 2024 case TableTBodies: return getHTMLCollection(exec, table.tBodies().get()); // type HTMLCollection 2025 case TableAlign: return String(table.align()); 2026 case TableBgColor: return String(table.bgColor()); 2027 case TableBorder: return String(table.border()); 2028 case TableCellPadding: return String(table.cellPadding()); 2029 case TableCellSpacing: return String(table.cellSpacing()); 2030 case TableFrame: return String(table.frame()); 2031 case TableRules: return String(table.rules()); 2032 case TableSummary: return String(table.summary()); 2033 case TableWidth: return String(table.width()); 2034 } 2035 return Undefined(); 2036 } 2037 2038 Value HTMLElement::tableCaptionGetter(ExecState* exec, int token) const 2039 { 2040 HTMLTableCaptionElementImpl& tableCaption = *static_cast<HTMLTableCaptionElementImpl*>(impl()); 2041 if (token == TableCaptionAlign) 2042 return String(tableCaption.align()); 2043 return Undefined(); 2044 } 2045 2046 Value HTMLElement::tableColGetter(ExecState* exec, int token) const 2047 { 2048 HTMLTableColElementImpl& tableCol = *static_cast<HTMLTableColElementImpl*>(impl()); 2049 switch (token) { 2050 case TableColAlign: return String(tableCol.align()); 2051 case TableColCh: return String(tableCol.ch()); 2052 case TableColChOff: return String(tableCol.chOff()); 2053 case TableColSpan: return Number(tableCol.span()); 2054 case TableColVAlign: return String(tableCol.vAlign()); 2055 case TableColWidth: return String(tableCol.width()); 2056 } 2057 return Undefined(); 2058 } 2059 2060 Value HTMLElement::tableSectionGetter(ExecState* exec, int token) const 2061 { 2062 HTMLTableSectionElementImpl& tableSection = *static_cast<HTMLTableSectionElementImpl*>(impl()); 2063 switch (token) { 2064 case TableSectionAlign: return String(tableSection.align()); 2065 case TableSectionCh: return String(tableSection.ch()); 2066 case TableSectionChOff: return String(tableSection.chOff()); 2067 case TableSectionVAlign: return String(tableSection.vAlign()); 2068 case TableSectionRows: return getHTMLCollection(exec, tableSection.rows().get()); // type HTMLCollection 2069 } 2070 return Undefined(); 2071 } 2072 2073 Value HTMLElement::tableRowGetter(ExecState* exec, int token) const 2074 { 2075 HTMLTableRowElementImpl& tableRow = *static_cast<HTMLTableRowElementImpl*>(impl()); 2076 switch (token) { 2077 case TableRowRowIndex: return Number(tableRow.rowIndex()); 2078 case TableRowSectionRowIndex: return Number(tableRow.sectionRowIndex()); 2079 case TableRowCells: return getHTMLCollection(exec, tableRow.cells().get()); // type HTMLCollection 2080 case TableRowAlign: return String(tableRow.align()); 2081 case TableRowBgColor: return String(tableRow.bgColor()); 2082 case TableRowCh: return String(tableRow.ch()); 2083 case TableRowChOff: return String(tableRow.chOff()); 2084 case TableRowVAlign: return String(tableRow.vAlign()); 2085 } 2086 return Undefined(); 2087 } 2088 2089 Value HTMLElement::tableCellGetter(ExecState* exec, int token) const 2090 { 2091 HTMLTableCellElementImpl& tableCell = *static_cast<HTMLTableCellElementImpl*>(impl()); 2092 switch (token) { 2093 case TableCellCellIndex: return Number(tableCell.cellIndex()); 2094 case TableCellAbbr: return String(tableCell.abbr()); 2095 case TableCellAlign: return String(tableCell.align()); 2096 case TableCellAxis: return String(tableCell.axis()); 2097 case TableCellBgColor: return String(tableCell.bgColor()); 2098 case TableCellCh: return String(tableCell.ch()); 2099 case TableCellChOff: return String(tableCell.chOff()); 2100 case TableCellColSpan: return Number(tableCell.colSpan()); 2101 case TableCellHeaders: return String(tableCell.headers()); 2102 case TableCellHeight: return String(tableCell.height()); 2103 case TableCellNoWrap: return Boolean(tableCell.noWrap()); 2104 case TableCellRowSpan: return Number(tableCell.rowSpan()); 2105 case TableCellScope: return String(tableCell.scope()); 2106 case TableCellVAlign: return String(tableCell.vAlign()); 2107 case TableCellWidth: return String(tableCell.width()); 2108 } 2109 return Undefined(); 2110 } 2111 2112 Value HTMLElement::frameSetGetter(ExecState* exec, int token) const 2113 { 2114 HTMLFrameSetElementImpl& frameSet = *static_cast<HTMLFrameSetElementImpl*>(impl()); 2115 switch (token) { 2116 case FrameSetCols: return String(frameSet.cols()); 2117 case FrameSetRows: return String(frameSet.rows()); 2118 } 2119 return Undefined(); 2120 } 2121 2122 Value HTMLElement::frameGetter(ExecState* exec, int token) const 2123 { 2124 HTMLFrameElementImpl& frameElement = *static_cast<HTMLFrameElementImpl*>(impl()); 2125 switch (token) { 2126 case FrameContentDocument: return checkNodeSecurity(exec,frameElement.contentDocument()) ? 2127 getDOMNode(exec, frameElement.contentDocument()) : Undefined(); 2128 case FrameContentWindow: return checkNodeSecurity(exec,frameElement.contentDocument()) 2129 ? Window::retrieve(frameElement.contentPart()) 2130 : Undefined(); 2131 case FrameFrameBorder: return String(frameElement.frameBorder()); 2132 case FrameLongDesc: return String(frameElement.longDesc()); 2133 case FrameMarginHeight: return String(frameElement.marginHeight()); 2134 case FrameMarginWidth: return String(frameElement.marginWidth()); 2135 case FrameName: return String(frameElement.name()); 2136 case FrameNoResize: return Boolean(frameElement.noResize()); 2137 case FrameScrolling: return String(frameElement.scrolling()); 2138 case FrameSrc: 2139 case FrameLocation: return String(frameElement.src()); 2140 } 2141 return Undefined(); 2142 } 2143 2144 Value HTMLElement::iFrameGetter(ExecState* exec, int token) const 2145 { 2146 HTMLIFrameElementImpl& iFrame = *static_cast<HTMLIFrameElementImpl*>(impl()); 2147 switch (token) { 2148 case IFrameAlign: return String(iFrame.align()); 2149 // ### security check ? 2150 case IFrameDocument: // non-standard, mapped to contentDocument 2151 case IFrameContentDocument: return checkNodeSecurity(exec,iFrame.contentDocument()) ? 2152 getDOMNode(exec, iFrame.contentDocument()) : Undefined(); 2153 case IFrameContentWindow: return checkNodeSecurity(exec,iFrame.contentDocument()) 2154 ? Window::retrieve(iFrame.contentPart()) 2155 : Undefined(); 2156 case IFrameFrameBorder: return String(iFrame.frameBorder()); 2157 case IFrameHeight: return String(iFrame.height()); 2158 case IFrameLongDesc: return String(iFrame.longDesc()); 2159 case IFrameMarginHeight: return String(iFrame.marginHeight()); 2160 case IFrameMarginWidth: return String(iFrame.marginWidth()); 2161 case IFrameName: return String(iFrame.name()); 2162 case IFrameScrolling: return String(iFrame.scrolling()); 2163 case IFrameSrc: return String(iFrame.src()); 2164 case IFrameWidth: return String(iFrame.width()); 2165 } 2166 return Undefined(); 2167 } 2168 2169 Value HTMLElement::marqueeGetter(ExecState* exec, int token) const 2170 { 2171 // FIXME: Find out what WinIE exposes as properties and implement this. 2172 return Undefined(); 2173 } 2174 2175 Value HTMLElement::getValueProperty(ExecState *exec, int token) const 2176 { 2177 // Check our set of generic properties first. 2178 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl()); 2179 switch (token) { 2180 case ElementId: 2181 // iht.com relies on this value being "" when no id is present. Other browsers do this as well. 2182 // So we use String() instead of String() here. 2183 return String(element.id()); 2184 case ElementTitle: 2185 return String(element.title()); 2186 case ElementLang: 2187 return String(element.lang()); 2188 case ElementDir: 2189 return String(element.dir()); 2190 case ElementClassName: 2191 return String(element.className()); 2192 case ElementInnerHTML: 2193 return String(element.innerHTML()); 2194 case ElementInnerText: 2195 if (DocumentImpl* doc = impl()->getDocument()) 2196 doc->updateLayoutIgnorePendingStylesheets(); 2197 return String(element.innerText()); 2198 case ElementOuterHTML: 2199 return String(element.outerHTML()); 2200 case ElementOuterText: 2201 return String(element.outerText()); 2202 case ElementDocument: 2203 return getDOMNode(exec,element.ownerDocument()); 2204 case ElementChildren: 2205 return getHTMLCollection(exec, element.children().get()); 2206 case ElementContentEditable: 2207 return String(element.contentEditable()); 2208 case ElementIsContentEditable: 2209 return Boolean(element.isContentEditable()); 2210 } 2211 2212 // Now check the properties specific to our element type. 2213 const Accessors* info = getSetInfo(); 2214 if (info && info->m_getter) 2215 return (this->*(info->m_getter))(exec, token); 2216 return Undefined(); 2053 2217 } 2054 2218 … … 2056 2220 { 2057 2221 #ifdef KJS_VERBOSE 2058 //kdDebug(6070) << "HTMLElement::hasProperty " << propertyName.qstring() << endl;2222 //kdDebug(6070) << "HTMLElement::hasProperty " << propertyName.qstring() << endl; 2059 2223 #endif 2060 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl()); 2061 // First look at dynamic properties - keep this in sync with tryGet 2062 switch (element.id()) { 2063 case ID_FORM: { 2064 HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element); 2065 // Check if we're retrieving an element (by index or by name) 2066 bool ok; 2067 uint u = propertyName.toULong(&ok); 2068 if (ok && form.elements()->item(u)) 2069 return true; 2070 if (form.elements()->namedItem(propertyName.string())) 2071 return true; 2072 break; 2073 } 2074 case ID_SELECT: { 2075 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 2076 bool ok; 2077 uint u = propertyName.toULong(&ok); 2078 if (ok && select.optionsHTMLCollection()->item(u)) 2079 return true; 2080 break; 2081 } 2082 case ID_INPUT: { 2083 HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element); 2084 const HashTable* table = classInfo()->propHashTable; 2085 const HashEntry* entry = Lookup::findEntry(table, propertyName); 2086 if (entry) { 2087 switch(entry->value) { 2088 case InputSelectionStart: 2089 case InputSelectionEnd: 2090 case InputSetSelectionRange: 2091 return input.canHaveSelection(); 2092 default: 2093 break; 2094 } 2095 } 2096 break; 2097 } 2098 default: 2099 break; 2100 } 2101 2102 return DOMElement::hasOwnProperty(exec, propertyName); 2224 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl()); 2225 // First look at dynamic properties - keep this in sync with tryGet 2226 if (element.hasLocalName(HTMLNames::form())) { 2227 HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element); 2228 // Check if we're retrieving an element (by index or by name) 2229 bool ok; 2230 uint u = propertyName.toULong(&ok); 2231 if (ok && form.elements()->item(u)) 2232 return true; 2233 if (form.elements()->namedItem(propertyName.string())) 2234 return true; 2235 } 2236 else if (element.hasLocalName(HTMLNames::select())) { 2237 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 2238 bool ok; 2239 uint u = propertyName.toULong(&ok); 2240 if (ok && select.optionsHTMLCollection()->item(u)) 2241 return true; 2242 } 2243 else if (element.hasLocalName(HTMLNames::input())) { 2244 HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element); 2245 const HashTable* table = classInfo()->propHashTable; 2246 const HashEntry* entry = Lookup::findEntry(table, propertyName); 2247 if (entry) { 2248 switch(entry->value) { 2249 case InputSelectionStart: 2250 case InputSelectionEnd: 2251 case InputSetSelectionRange: 2252 return input.canHaveSelection(); 2253 default: 2254 break; 2255 } 2256 } 2257 } 2258 2259 return DOMElement::hasOwnProperty(exec, propertyName); 2103 2260 } 2104 2261 2105 2262 UString KJS::HTMLElement::toString(ExecState *exec) const 2106 2263 { 2107 if (impl()->id() == ID_A)2108 return UString(static_cast<const HTMLAnchorElementImpl *>(impl())->href());2109 else2110 return DOMElement::toString(exec);2264 if (impl()->hasTagName(HTMLNames::a())) 2265 return UString(static_cast<const HTMLAnchorElementImpl *>(impl())->href()); 2266 else 2267 return DOMElement::toString(exec); 2111 2268 } 2112 2269 2113 2270 static HTMLFormElementImpl *getForm(HTMLElementImpl *element) 2114 2271 { 2115 if (element->isGenericFormElement()) 2116 return static_cast<HTMLGenericFormElementImpl *>(element)->form(); 2117 2118 switch (element->id()) { 2119 case ID_LABEL: 2120 return static_cast<HTMLLabelElementImpl *>(element)->form(); 2121 case ID_OBJECT: 2122 return static_cast<HTMLObjectElementImpl *>(element)->form(); 2123 } 2124 2125 return 0; 2272 if (element->isGenericFormElement()) 2273 return static_cast<HTMLGenericFormElementImpl *>(element)->form(); 2274 if (element->hasTagName(HTMLNames::label())) 2275 return static_cast<HTMLLabelElementImpl *>(element)->form(); 2276 if (element->hasTagName(HTMLNames::object())) 2277 return static_cast<HTMLObjectElementImpl *>(element)->form(); 2278 2279 return 0; 2126 2280 } 2127 2281 … … 2143 2297 else { 2144 2298 NodeImpl *form = element->parentNode(); 2145 while (form && form->id() != ID_FORM)2299 while (form && !form->hasTagName(HTMLNames::form())) 2146 2300 form = form->parentNode(); 2147 2301 … … 2163 2317 Value KJS::HTMLElementFunction::tryCall(ExecState *exec, Object &thisObj, const List &args) 2164 2318 { 2165 if (!thisObj.inherits(&KJS::HTMLElement::info)) { 2166 Object err = Error::create(exec,TypeError); 2167 exec->setException(err); 2168 return err; 2169 } 2170 kdDebug() << "KJS::HTMLElementFunction::tryCall " << endl; 2171 DOMExceptionTranslator exception(exec); 2172 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(static_cast<HTMLElement *>(thisObj.imp())->impl()); 2173 2174 switch (element.id()) { 2175 case ID_FORM: { 2176 HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element); 2177 if (id == KJS::HTMLElement::FormSubmit) { 2178 form.submit(); 2179 return Undefined(); 2180 } 2181 else if (id == KJS::HTMLElement::FormReset) { 2182 form.reset(); 2183 return Undefined(); 2184 } 2185 } 2186 break; 2187 case ID_SELECT: { 2188 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 2189 if (id == KJS::HTMLElement::SelectAdd) { 2190 select.add(toHTMLElement(args[0]), toHTMLElement(args[1])); 2191 return Undefined(); 2192 } 2193 else if (id == KJS::HTMLElement::SelectRemove) { 2194 select.remove(int(args[0].toNumber(exec))); 2195 return Undefined(); 2196 } 2197 else if (id == KJS::HTMLElement::SelectBlur) { 2198 select.blur(); 2199 return Undefined(); 2200 } 2201 else if (id == KJS::HTMLElement::SelectFocus) { 2202 select.focus(); 2203 return Undefined(); 2204 } 2205 } 2206 break; 2207 case ID_INPUT: { 2208 HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element); 2209 if (id == KJS::HTMLElement::InputBlur) { 2210 input.blur(); 2211 return Undefined(); 2212 } 2213 else if (id == KJS::HTMLElement::InputFocus) { 2214 input.focus(); 2215 return Undefined(); 2216 } 2217 else if (id == KJS::HTMLElement::InputSelect) { 2218 input.select(); 2219 return Undefined(); 2220 } 2221 else if (id == KJS::HTMLElement::InputClick) { 2222 input.click(); 2223 return Undefined(); 2224 } 2225 else if (id == KJS::HTMLElement::InputSetSelectionRange) { 2226 input.setSelectionRange(args[0].toInt32(exec), args[1].toInt32(exec)); 2227 return Undefined(); 2228 } 2229 } 2230 break; 2231 case ID_LABEL: { 2232 HTMLLabelElementImpl &label = static_cast<HTMLLabelElementImpl &>(element); 2233 2234 if (id == KJS::HTMLElement::LabelFocus) { 2235 label.focus(); 2236 return Undefined(); 2237 } 2238 } 2239 break; 2240 case ID_LEGEND: { 2241 HTMLLegendElementImpl &legend = static_cast<HTMLLegendElementImpl &>(element); 2242 2243 if (id == KJS::HTMLElement::LegendFocus) { 2244 legend.focus(); 2245 return Undefined(); 2246 } 2247 } 2248 break; 2249 case ID_BUTTON: { 2250 HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element); 2251 2252 if (id == KJS::HTMLElement::ButtonBlur) { 2253 button.blur(); 2254 return Undefined(); 2255 } 2256 else if (id == KJS::HTMLElement::ButtonFocus) { 2257 button.focus(); 2258 return Undefined(); 2259 } 2260 } 2261 break; 2262 case ID_TEXTAREA: { 2263 HTMLTextAreaElementImpl &textarea = static_cast<HTMLTextAreaElementImpl &>(element); 2264 if (id == KJS::HTMLElement::TextAreaBlur) { 2265 textarea.blur(); 2266 return Undefined(); 2267 } 2268 else if (id == KJS::HTMLElement::TextAreaFocus) { 2269 textarea.focus(); 2270 return Undefined(); 2271 } 2272 else if (id == KJS::HTMLElement::TextAreaSelect) { 2273 textarea.select(); 2274 return Undefined(); 2275 } 2276 else if (id == KJS::HTMLElement::TextAreaSetSelectionRange) { 2277 textarea.setSelectionRange(args[0].toInt32(exec), args[1].toInt32(exec)); 2278 return Undefined(); 2279 } 2280 } 2281 break; 2282 case ID_A: { 2283 HTMLAnchorElementImpl &anchor = static_cast<HTMLAnchorElementImpl &>(element); 2284 if (id == KJS::HTMLElement::AnchorBlur) { 2285 anchor.blur(); 2286 return Undefined(); 2287 } 2288 else if (id == KJS::HTMLElement::AnchorFocus) { 2289 anchor.focus(); 2290 return Undefined(); 2291 } 2292 else if (id == KJS::HTMLElement::AnchorToString) { 2293 return String(thisObj.toString(exec)); 2294 } 2295 } 2296 break; 2297 case ID_TABLE: { 2298 HTMLTableElementImpl &table = static_cast<HTMLTableElementImpl &>(element); 2299 if (id == KJS::HTMLElement::TableCreateTHead) 2300 return getDOMNode(exec,table.createTHead()); 2301 else if (id == KJS::HTMLElement::TableDeleteTHead) { 2302 table.deleteTHead(); 2303 return Undefined(); 2304 } 2305 else if (id == KJS::HTMLElement::TableCreateTFoot) 2306 return getDOMNode(exec,table.createTFoot()); 2307 else if (id == KJS::HTMLElement::TableDeleteTFoot) { 2308 table.deleteTFoot(); 2309 return Undefined(); 2310 } 2311 else if (id == KJS::HTMLElement::TableCreateCaption) 2312 return getDOMNode(exec,table.createCaption()); 2313 else if (id == KJS::HTMLElement::TableDeleteCaption) { 2314 table.deleteCaption(); 2315 return Undefined(); 2316 } 2317 else if (id == KJS::HTMLElement::TableInsertRow) 2318 return getDOMNode(exec,table.insertRow(args[0].toInt32(exec), exception)); 2319 else if (id == KJS::HTMLElement::TableDeleteRow) { 2320 table.deleteRow(args[0].toInt32(exec), exception); 2321 return Undefined(); 2322 } 2323 } 2324 break; 2325 case ID_THEAD: 2326 case ID_TBODY: 2327 case ID_TFOOT: { 2328 HTMLTableSectionElementImpl &tableSection = static_cast<HTMLTableSectionElementImpl &>(element); 2329 if (id == KJS::HTMLElement::TableSectionInsertRow) 2330 return getDOMNode(exec, tableSection.insertRow(args[0].toInt32(exec), exception)); 2331 else if (id == KJS::HTMLElement::TableSectionDeleteRow) { 2332 tableSection.deleteRow(args[0].toInt32(exec), exception); 2333 return Undefined(); 2334 } 2335 } 2336 break; 2337 case ID_TR: { 2338 HTMLTableRowElementImpl &tableRow = static_cast<HTMLTableRowElementImpl &>(element); 2339 if (id == KJS::HTMLElement::TableRowInsertCell) 2340 return getDOMNode(exec,tableRow.insertCell(args[0].toInt32(exec), exception)); 2341 else if (id == KJS::HTMLElement::TableRowDeleteCell) { 2342 tableRow.deleteCell(args[0].toInt32(exec), exception); 2343 return Undefined(); 2344 } 2345 } 2346 case ID_MARQUEE: { 2319 if (!thisObj.inherits(&KJS::HTMLElement::info)) { 2320 Object err = Error::create(exec,TypeError); 2321 exec->setException(err); 2322 return err; 2323 } 2324 kdDebug() << "KJS::HTMLElementFunction::tryCall " << endl; 2325 DOMExceptionTranslator exception(exec); 2326 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(static_cast<HTMLElement *>(thisObj.imp())->impl()); 2327 2328 if (element.hasLocalName(HTMLNames::form())) { 2329 HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element); 2330 if (id == KJS::HTMLElement::FormSubmit) { 2331 form.submit(); 2332 return Undefined(); 2333 } 2334 else if (id == KJS::HTMLElement::FormReset) { 2335 form.reset(); 2336 return Undefined(); 2337 } 2338 } 2339 else if (element.hasLocalName(HTMLNames::select())) { 2340 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 2341 if (id == KJS::HTMLElement::SelectAdd) { 2342 select.add(toHTMLElement(args[0]), toHTMLElement(args[1])); 2343 return Undefined(); 2344 } 2345 else if (id == KJS::HTMLElement::SelectRemove) { 2346 select.remove(int(args[0].toNumber(exec))); 2347 return Undefined(); 2348 } 2349 else if (id == KJS::HTMLElement::SelectBlur) { 2350 select.blur(); 2351 return Undefined(); 2352 } 2353 else if (id == KJS::HTMLElement::SelectFocus) { 2354 select.focus(); 2355 return Undefined(); 2356 } 2357 } 2358 else if (element.hasLocalName(HTMLNames::input())) { 2359 HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element); 2360 if (id == KJS::HTMLElement::InputBlur) { 2361 input.blur(); 2362 return Undefined(); 2363 } 2364 else if (id == KJS::HTMLElement::InputFocus) { 2365 input.focus(); 2366 return Undefined(); 2367 } 2368 else if (id == KJS::HTMLElement::InputSelect) { 2369 input.select(); 2370 return Undefined(); 2371 } 2372 else if (id == KJS::HTMLElement::InputClick) { 2373 input.click(); 2374 return Undefined(); 2375 } 2376 else if (id == KJS::HTMLElement::InputSetSelectionRange) { 2377 input.setSelectionRange(args[0].toInt32(exec), args[1].toInt32(exec)); 2378 return Undefined(); 2379 } 2380 } 2381 else if (element.hasLocalName(HTMLNames::button())) { 2382 HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element); 2383 if (id == KJS::HTMLElement::ButtonBlur) { 2384 button.blur(); 2385 return Undefined(); 2386 } 2387 else if (id == KJS::HTMLElement::ButtonFocus) { 2388 button.focus(); 2389 return Undefined(); 2390 } 2391 } 2392 else if (element.hasLocalName(HTMLNames::label())) { 2393 HTMLLabelElementImpl &label = static_cast<HTMLLabelElementImpl &>(element); 2394 if (id == KJS::HTMLElement::LabelFocus) { 2395 label.focus(); 2396 return Undefined(); 2397 } 2398 } 2399 else if (element.hasLocalName(HTMLNames::legend())) { 2400 HTMLLegendElementImpl &legend = static_cast<HTMLLegendElementImpl &>(element); 2401 if (id == KJS::HTMLElement::LegendFocus) { 2402 legend.focus(); 2403 return Undefined(); 2404 } 2405 } 2406 else if (element.hasLocalName(HTMLNames::textarea())) { 2407 HTMLTextAreaElementImpl &textarea = static_cast<HTMLTextAreaElementImpl &>(element); 2408 if (id == KJS::HTMLElement::TextAreaBlur) { 2409 textarea.blur(); 2410 return Undefined(); 2411 } 2412 else if (id == KJS::HTMLElement::TextAreaFocus) { 2413 textarea.focus(); 2414 return Undefined(); 2415 } 2416 else if (id == KJS::HTMLElement::TextAreaSelect) { 2417 textarea.select(); 2418 return Undefined(); 2419 } 2420 else if (id == KJS::HTMLElement::TextAreaSetSelectionRange) { 2421 textarea.setSelectionRange(args[0].toInt32(exec), args[1].toInt32(exec)); 2422 return Undefined(); 2423 } 2424 } 2425 else if (element.hasLocalName(HTMLNames::a())) { 2426 HTMLAnchorElementImpl &anchor = static_cast<HTMLAnchorElementImpl &>(element); 2427 if (id == KJS::HTMLElement::AnchorBlur) { 2428 anchor.blur(); 2429 return Undefined(); 2430 } 2431 else if (id == KJS::HTMLElement::AnchorFocus) { 2432 anchor.focus(); 2433 return Undefined(); 2434 } 2435 else if (id == KJS::HTMLElement::AnchorToString) 2436 return String(thisObj.toString(exec)); 2437 } 2438 else if (element.hasLocalName(HTMLNames::table())) { 2439 HTMLTableElementImpl &table = static_cast<HTMLTableElementImpl &>(element); 2440 if (id == KJS::HTMLElement::TableCreateTHead) 2441 return getDOMNode(exec,table.createTHead()); 2442 else if (id == KJS::HTMLElement::TableDeleteTHead) { 2443 table.deleteTHead(); 2444 return Undefined(); 2445 } 2446 else if (id == KJS::HTMLElement::TableCreateTFoot) 2447 return getDOMNode(exec,table.createTFoot()); 2448 else if (id == KJS::HTMLElement::TableDeleteTFoot) { 2449 table.deleteTFoot(); 2450 return Undefined(); 2451 } 2452 else if (id == KJS::HTMLElement::TableCreateCaption) 2453 return getDOMNode(exec,table.createCaption()); 2454 else if (id == KJS::HTMLElement::TableDeleteCaption) { 2455 table.deleteCaption(); 2456 return Undefined(); 2457 } 2458 else if (id == KJS::HTMLElement::TableInsertRow) 2459 return getDOMNode(exec,table.insertRow(args[0].toInt32(exec), exception)); 2460 else if (id == KJS::HTMLElement::TableDeleteRow) { 2461 table.deleteRow(args[0].toInt32(exec), exception); 2462 return Undefined(); 2463 } 2464 } 2465 else if (element.hasLocalName(HTMLNames::thead()) || 2466 element.hasLocalName(HTMLNames::tbody()) || 2467 element.hasLocalName(HTMLNames::tfoot())) { 2468 HTMLTableSectionElementImpl &tableSection = static_cast<HTMLTableSectionElementImpl &>(element); 2469 if (id == KJS::HTMLElement::TableSectionInsertRow) 2470 return getDOMNode(exec, tableSection.insertRow(args[0].toInt32(exec), exception)); 2471 else if (id == KJS::HTMLElement::TableSectionDeleteRow) { 2472 tableSection.deleteRow(args[0].toInt32(exec), exception); 2473 return Undefined(); 2474 } 2475 } 2476 else if (element.hasLocalName(HTMLNames::tr())) { 2477 HTMLTableRowElementImpl &tableRow = static_cast<HTMLTableRowElementImpl &>(element); 2478 if (id == KJS::HTMLElement::TableRowInsertCell) 2479 return getDOMNode(exec,tableRow.insertCell(args[0].toInt32(exec), exception)); 2480 else if (id == KJS::HTMLElement::TableRowDeleteCell) { 2481 tableRow.deleteCell(args[0].toInt32(exec), exception); 2482 return Undefined(); 2483 } 2484 } 2485 else if (element.hasLocalName(HTMLNames::marquee())) { 2347 2486 if (id == KJS::HTMLElement::MarqueeStart && element.renderer() && 2348 2487 element.renderer()->layer() && … … 2352 2491 } 2353 2492 if (id == KJS::HTMLElement::MarqueeStop && element.renderer() && 2354 2355 2493 element.renderer()->layer() && 2494 element.renderer()->layer()->marquee()) { 2356 2495 element.renderer()->layer()->marquee()->stop(); 2357 2496 return Undefined(); 2358 2497 } 2359 break;2360 } 2361 case ID_CANVAS:{2498 } 2499 #if APPLE_CHANGES 2500 else if (element.hasLocalName(HTMLNames::canvas())) { 2362 2501 if (id == KJS::HTMLElement::GetContext) { 2363 2502 if (args.size() == 0 || (args.size() == 1 && args[0].toString(exec).qstring().lower() == "2d")) { … … 2367 2506 } 2368 2507 } 2369 2370 break; 2371 } 2372 2373 return Undefined(); 2508 #endif 2509 2510 return Undefined(); 2374 2511 } 2375 2512 … … 2377 2514 { 2378 2515 #ifdef KJS_VERBOSE 2379 DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string();2516 DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string(); 2380 2517 #endif 2381 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl());2518 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl()); 2382 2519 #ifdef KJS_VERBOSE 2383 kdDebug(6070) << "KJS::HTMLElement::tryPut " << propertyName.qstring()2384 << " thisTag=" << element.tagName().string()2385 << " str=" << str.string() << endl;2520 kdDebug(6070) << "KJS::HTMLElement::tryPut " << propertyName.qstring() 2521 << " thisTag=" << element.tagName().string() 2522 << " str=" << str.string() << endl; 2386 2523 #endif 2387 // First look at dynamic properties 2388 switch (element.id()) { 2389 case ID_SELECT: { 2390 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 2391 bool ok; 2392 /*uint u =*/ propertyName.toULong(&ok); 2393 if (ok) { 2394 Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.optionsHTMLCollection().get(), &select) ); 2395 if ( !coll.isNull() ) 2396 coll.put(exec,propertyName,value); 2397 return; 2398 } 2524 // First look at dynamic properties 2525 if (element.hasLocalName(HTMLNames::select())) { 2526 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 2527 bool ok; 2528 /*uint u =*/ propertyName.toULong(&ok); 2529 if (ok) { 2530 Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.optionsHTMLCollection().get(), &select) ); 2531 if (!coll.isNull()) 2532 coll.put(exec,propertyName,value); 2533 return; 2534 } 2399 2535 } 2400 2536 #if APPLE_CHANGES 2401 case ID_EMBED:2402 case ID_OBJECT:2403 case ID_APPLET:{2537 else if (element.hasLocalName(HTMLNames::embed()) || 2538 element.hasLocalName(HTMLNames::object()) || 2539 element.hasLocalName(HTMLNames::applet())) { 2404 2540 Value runtimeObject = getRuntimeObject(exec,&element); 2405 2541 if (!runtimeObject.isNull()) { 2406 2542 ObjectImp *imp = static_cast<ObjectImp *>(runtimeObject.imp()); 2407 if (imp->canPut(exec, propertyName)) {2543 if (imp->canPut(exec, propertyName)) 2408 2544 return imp->put (exec, propertyName, value); 2409 }2410 2545 } 2411 2546 } 2412 break;2413 2547 #endif 2414 break; 2415 default: 2416 break; 2417 } 2418 2419 const HashTable* table = classInfo()->propHashTable; // get the right hashtable 2420 const HashEntry* entry = Lookup::findEntry(table, propertyName); 2421 if (entry) { 2422 if (entry->attr & Function) // function: put as override property 2423 { 2424 ObjectImp::put(exec, propertyName, value, attr); 2425 return; 2426 } 2427 else if ((entry->attr & ReadOnly) == 0) // let DOMObjectLookupPut print the warning if not 2428 { 2429 putValue(exec, entry->value, value, attr); 2430 return; 2431 } 2432 } 2433 DOMObjectLookupPut<KJS::HTMLElement, DOMElement>(exec, propertyName, value, attr, &HTMLElementTable, this); 2434 } 2435 2436 void HTMLElement::putValue(ExecState *exec, int token, const Value& value, int) 2437 { 2438 DOMExceptionTranslator exception(exec); 2439 DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string(); 2440 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl()); 2441 #ifdef KJS_VERBOSE 2442 kdDebug(6070) << "KJS::HTMLElement::putValue " 2443 << " thisTag=" << element.tagName().string() 2444 << " token=" << token << endl; 2445 #endif 2446 2447 switch (element.id()) { 2448 case ID_HTML: { 2449 HTMLHtmlElementImpl &html = static_cast<HTMLHtmlElementImpl &>(element); 2450 switch (token) { 2451 case HtmlVersion: { html.setVersion(str); return; } 2452 } 2453 } 2454 break; 2455 case ID_HEAD: { 2456 HTMLHeadElementImpl &head = static_cast<HTMLHeadElementImpl &>(element); 2457 switch (token) { 2458 case HeadProfile: { head.setProfile(str); return; } 2459 } 2460 } 2461 break; 2462 case ID_LINK: { 2463 HTMLLinkElementImpl &link = static_cast<HTMLLinkElementImpl &>(element); 2464 switch (token) { 2465 case LinkDisabled: { link.setDisabled(value.toBoolean(exec)); return; } 2466 case LinkCharset: { link.setCharset(str); return; } 2467 case LinkHref: { link.setHref(str); return; } 2468 case LinkHrefLang: { link.setHreflang(str); return; } 2469 case LinkMedia: { link.setMedia(str); return; } 2470 case LinkRel: { link.setRel(str); return; } 2471 case LinkRev: { link.setRev(str); return; } 2472 case LinkTarget: { link.setTarget(str); return; } 2473 case LinkType: { link.setType(str); return; } 2474 } 2475 } 2476 break; 2477 case ID_TITLE: { 2478 HTMLTitleElementImpl &title = static_cast<HTMLTitleElementImpl &>(element); 2479 switch (token) { 2480 case TitleText: { title.setText(str); return; } 2481 } 2482 } 2483 break; 2484 case ID_META: { 2485 HTMLMetaElementImpl &meta = static_cast<HTMLMetaElementImpl &>(element); 2486 switch (token) { 2487 case MetaContent: { meta.setContent(str); return; } 2488 case MetaHttpEquiv: { meta.setHttpEquiv(str); return; } 2489 case MetaName: { meta.setName(str); return; } 2490 case MetaScheme: { meta.setScheme(str); return; } 2491 } 2492 } 2493 break; 2494 case ID_BASE: { 2495 HTMLBaseElementImpl &base = static_cast<HTMLBaseElementImpl &>(element); 2496 switch (token) { 2497 case BaseHref: { base.setHref(str); return; } 2498 case BaseTarget: { base.setTarget(str); return; } 2499 } 2500 } 2501 break; 2502 case ID_ISINDEX: { 2503 HTMLIsIndexElementImpl &isindex = static_cast<HTMLIsIndexElementImpl &>(element); 2504 switch (token) { 2505 // read-only: form 2506 case IsIndexPrompt: { isindex.setPrompt(str); return; } 2507 } 2508 } 2509 break; 2510 case ID_STYLE: { 2511 HTMLStyleElementImpl &style = static_cast<HTMLStyleElementImpl &>(element); 2512 switch (token) { 2513 case StyleDisabled: { style.setDisabled(value.toBoolean(exec)); return; } 2514 case StyleMedia: { style.setMedia(str); return; } 2515 case StyleType: { style.setType(str); return; } 2516 } 2517 } 2518 break; 2519 case ID_BODY: { 2520 HTMLBodyElementImpl &body = static_cast<HTMLBodyElementImpl &>(element); 2521 switch (token) { 2522 case BodyALink: { body.setALink(str); return; } 2523 case BodyBackground: { body.setBackground(str); return; } 2524 case BodyBgColor: { body.setBgColor(str); return; } 2525 case BodyLink: { body.setLink(str); return; } 2526 case BodyText: { body.setText(str); return; } 2527 case BodyVLink: { body.setVLink(str); return; } 2528 case BodyScrollLeft: 2529 case BodyScrollTop: { 2530 QScrollView* sview = body.ownerDocument()->view(); 2531 if (sview) { 2532 // Update the document's layout before we compute these attributes. 2533 if (DocumentImpl* doc = body.getDocument()) 2534 doc->updateLayoutIgnorePendingStylesheets(); 2535 if (token == BodyScrollLeft) 2536 sview->setContentsPos(value.toInt32(exec), sview->contentsY()); 2537 else 2538 sview->setContentsPos(sview->contentsX(), value.toInt32(exec)); 2539 } 2540 return; 2541 } 2542 } 2543 } 2544 break; 2545 case ID_FORM: { 2546 HTMLFormElementImpl &form = static_cast<HTMLFormElementImpl &>(element); 2547 switch (token) { 2548 // read-only: elements 2549 // read-only: length 2550 case FormName: { form.setName(str); return; } 2551 case FormAcceptCharset: { form.setAcceptCharset(str); return; } 2552 case FormAction: { form.setAction(str); return; } 2553 case FormEncType: { form.setEnctype(str); return; } 2554 case FormMethod: { form.setMethod(str); return; } 2555 case FormTarget: { form.setTarget(str); return; } 2556 } 2557 } 2558 break; 2559 case ID_SELECT: { 2560 HTMLSelectElementImpl &select = static_cast<HTMLSelectElementImpl &>(element); 2561 switch (token) { 2562 // read-only: type 2563 case SelectSelectedIndex: { select.setSelectedIndex(value.toInt32(exec)); return; } 2564 case SelectValue: { select.setValue(str); return; } 2565 case SelectLength: { // read-only according to the NS spec, but webpages need it writeable 2548 2549 const HashTable* table = classInfo()->propHashTable; // get the right hashtable 2550 const HashEntry* entry = Lookup::findEntry(table, propertyName); 2551 if (entry) { 2552 if (entry->attr & Function) { // function: put as override property 2553 ObjectImp::put(exec, propertyName, value, attr); 2554 return; 2555 } 2556 else if ((entry->attr & ReadOnly) == 0) { // let DOMObjectLookupPut print the warning if not 2557 putValue(exec, entry->value, value, attr); 2558 return; 2559 } 2560 } 2561 2562 DOMObjectLookupPut<KJS::HTMLElement, DOMElement>(exec, propertyName, value, attr, &HTMLElementTable, this); 2563 } 2564 2565 void HTMLElement::htmlSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2566 { 2567 HTMLHeadElementImpl &head = *static_cast<HTMLHeadElementImpl*>(impl()); 2568 if (token == HeadProfile) 2569 head.setProfile(str); 2570 } 2571 2572 void HTMLElement::headSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2573 { 2574 HTMLHeadElementImpl &head = *static_cast<HTMLHeadElementImpl*>(impl()); 2575 if (token == HeadProfile) 2576 head.setProfile(str); 2577 } 2578 2579 void HTMLElement::linkSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2580 { 2581 HTMLLinkElementImpl &link = *static_cast<HTMLLinkElementImpl*>(impl()); 2582 switch (token) { 2583 case LinkDisabled: { link.setDisabled(value.toBoolean(exec)); return; } 2584 case LinkCharset: { link.setCharset(str); return; } 2585 case LinkHref: { link.setHref(str); return; } 2586 case LinkHrefLang: { link.setHreflang(str); return; } 2587 case LinkMedia: { link.setMedia(str); return; } 2588 case LinkRel: { link.setRel(str); return; } 2589 case LinkRev: { link.setRev(str); return; } 2590 case LinkTarget: { link.setTarget(str); return; } 2591 case LinkType: { link.setType(str); return; } 2592 } 2593 } 2594 2595 void HTMLElement::titleSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2596 { 2597 HTMLTitleElementImpl& title = *static_cast<HTMLTitleElementImpl*>(impl()); 2598 if (token == TitleText) 2599 title.setText(str); 2600 } 2601 2602 void HTMLElement::metaSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2603 { 2604 HTMLMetaElementImpl& meta = *static_cast<HTMLMetaElementImpl*>(impl()); 2605 switch (token) { 2606 case MetaContent: { meta.setContent(str); return; } 2607 case MetaHttpEquiv: { meta.setHttpEquiv(str); return; } 2608 case MetaName: { meta.setName(str); return; } 2609 case MetaScheme: { meta.setScheme(str); return; } 2610 } 2611 } 2612 2613 void HTMLElement::baseSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2614 { 2615 HTMLBaseElementImpl& base = *static_cast<HTMLBaseElementImpl*>(impl()); 2616 switch (token) { 2617 case BaseHref: { base.setHref(str); return; } 2618 case BaseTarget: { base.setTarget(str); return; } 2619 } 2620 } 2621 2622 void HTMLElement::isIndexSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2623 { 2624 HTMLIsIndexElementImpl& isindex = *static_cast<HTMLIsIndexElementImpl*>(impl()); 2625 if (token == IsIndexPrompt) 2626 isindex.setPrompt(str); 2627 } 2628 2629 void HTMLElement::styleSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2630 { 2631 HTMLStyleElementImpl& style = *static_cast<HTMLStyleElementImpl*>(impl()); 2632 switch (token) { 2633 case StyleDisabled: { style.setDisabled(value.toBoolean(exec)); return; } 2634 case StyleMedia: { style.setMedia(str); return; } 2635 case StyleType: { style.setType(str); return; } 2636 } 2637 } 2638 2639 void HTMLElement::bodySetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2640 { 2641 HTMLBodyElementImpl& body = *static_cast<HTMLBodyElementImpl*>(impl()); 2642 switch (token) { 2643 case BodyALink: { body.setALink(str); return; } 2644 case BodyBackground: { body.setBackground(str); return; } 2645 case BodyBgColor: { body.setBgColor(str); return; } 2646 case BodyLink: { body.setLink(str); return; } 2647 case BodyText: { body.setText(str); return; } 2648 case BodyVLink: { body.setVLink(str); return; } 2649 case BodyScrollLeft: 2650 case BodyScrollTop: { 2651 QScrollView* sview = body.ownerDocument()->view(); 2652 if (sview) { 2653 // Update the document's layout before we compute these attributes. 2654 if (DocumentImpl* doc = body.getDocument()) 2655 doc->updateLayoutIgnorePendingStylesheets(); 2656 if (token == BodyScrollLeft) 2657 sview->setContentsPos(value.toInt32(exec), sview->contentsY()); 2658 else 2659 sview->setContentsPos(sview->contentsX(), value.toInt32(exec)); 2660 } 2661 return; 2662 } 2663 } 2664 } 2665 2666 void HTMLElement::formSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2667 { 2668 HTMLFormElementImpl& form = *static_cast<HTMLFormElementImpl*>(impl()); 2669 switch (token) { 2670 // read-only: elements 2671 // read-only: length 2672 case FormName: { form.setName(str); return; } 2673 case FormAcceptCharset: { form.setAcceptCharset(str); return; } 2674 case FormAction: { form.setAction(str); return; } 2675 case FormEncType: { form.setEnctype(str); return; } 2676 case FormMethod: { form.setMethod(str); return; } 2677 case FormTarget: { form.setTarget(str); return; } 2678 } 2679 } 2680 2681 void HTMLElement::selectSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2682 { 2683 HTMLSelectElementImpl& select = *static_cast<HTMLSelectElementImpl*>(impl()); 2684 switch (token) { 2685 // read-only: type 2686 case SelectSelectedIndex: { select.setSelectedIndex(value.toInt32(exec)); return; } 2687 case SelectValue: { select.setValue(str); return; } 2688 case SelectLength: { // read-only according to the NS spec, but webpages need it writeable 2566 2689 Object coll = Object::dynamicCast( getSelectHTMLCollection(exec, select.optionsHTMLCollection().get(), &select) ); 2567 2690 if ( !coll.isNull() ) 2568 2691 coll.put(exec,lengthPropertyName,value); 2569 2692 return; 2570 } 2571 // read-only: form 2572 // read-only: options 2573 case SelectDisabled: { select.setDisabled(value.toBoolean(exec)); return; } 2574 case SelectMultiple: { select.setMultiple(value.toBoolean(exec)); return; } 2575 case SelectName: { select.setName(str); return; } 2576 case SelectSize: { select.setSize(value.toInt32(exec)); return; } 2577 case SelectTabIndex: { select.setTabIndex(value.toInt32(exec)); return; } 2578 } 2579 } 2580 break; 2581 case ID_OPTGROUP: { 2582 HTMLOptGroupElementImpl &optgroup = static_cast<HTMLOptGroupElementImpl &>(element); 2583 switch (token) { 2584 case OptGroupDisabled: { optgroup.setDisabled(value.toBoolean(exec)); return; } 2585 case OptGroupLabel: { optgroup.setLabel(str); return; } 2586 } 2587 } 2588 break; 2589 case ID_OPTION: { 2590 HTMLOptionElementImpl &option = static_cast<HTMLOptionElementImpl &>(element); 2591 switch (token) { 2592 // read-only: form 2593 case OptionDefaultSelected: { option.setDefaultSelected(value.toBoolean(exec)); return; } 2594 case OptionText: { option.setText(str, exception); return; } 2595 // read-only: index 2596 case OptionDisabled: { option.setDisabled(value.toBoolean(exec)); return; } 2597 case OptionLabel: { option.setLabel(str); return; } 2598 case OptionSelected: { option.setSelected(value.toBoolean(exec)); return; } 2599 case OptionValue: { option.setValue(str); return; } 2600 } 2601 } 2602 break; 2603 case ID_INPUT: { 2604 HTMLInputElementImpl &input = static_cast<HTMLInputElementImpl &>(element); 2605 switch (token) { 2606 case InputDefaultValue: { input.setDefaultValue(str); return; } 2607 case InputDefaultChecked: { input.setDefaultChecked(value.toBoolean(exec)); return; } 2608 // read-only: form 2609 case InputAccept: { input.setAccept(str); return; } 2610 case InputAccessKey: { input.setAccessKey(str); return; } 2611 case InputAlign: { input.setAlign(str); return; } 2612 case InputAlt: { input.setAlt(str); return; } 2613 case InputChecked: { input.setChecked(value.toBoolean(exec)); return; } 2614 case InputDisabled: { input.setDisabled(value.toBoolean(exec)); return; } 2615 case InputMaxLength: { input.setMaxLength(value.toInt32(exec)); return; } 2616 case InputName: { input.setName(str); return; } 2617 case InputReadOnly: { input.setReadOnly(value.toBoolean(exec)); return; } 2618 case InputSelectionStart: { input.setSelectionStart(value.toInt32(exec)); return; } 2619 case InputSelectionEnd: { input.setSelectionEnd(value.toInt32(exec)); return; } 2620 case InputSize: { input.setSize(str); return; } 2621 case InputSrc: { input.setSrc(str); return; } 2622 case InputTabIndex: { input.setTabIndex(value.toInt32(exec)); return; } 2623 case InputType: { input.setType(str); return; } 2624 case InputUseMap: { input.setUseMap(str); return; } 2625 case InputValue: { input.setValue(str); return; } 2626 } 2627 } 2628 break; 2629 case ID_TEXTAREA: { 2630 HTMLTextAreaElementImpl &textarea = static_cast<HTMLTextAreaElementImpl &>(element); 2631 switch (token) { 2632 case TextAreaDefaultValue: { textarea.setDefaultValue(str); return; } 2633 // read-only: form 2634 case TextAreaAccessKey: { textarea.setAccessKey(str); return; } 2635 case TextAreaCols: { textarea.setCols(value.toInt32(exec)); return; } 2636 case TextAreaDisabled: { textarea.setDisabled(value.toBoolean(exec)); return; } 2637 case TextAreaName: { textarea.setName(str); return; } 2638 case TextAreaReadOnly: { textarea.setReadOnly(value.toBoolean(exec)); return; } 2639 case TextAreaRows: { textarea.setRows(value.toInt32(exec)); return; } 2640 case TextAreaSelectionStart: { textarea.setSelectionStart(value.toInt32(exec)); return; } 2641 case TextAreaSelectionEnd: { textarea.setSelectionEnd(value.toInt32(exec)); return; } 2642 case TextAreaTabIndex: { textarea.setTabIndex(value.toInt32(exec)); return; } 2643 // read-only: type 2644 case TextAreaValue: { textarea.setValue(str); return; } 2645 } 2646 } 2647 break; 2648 case ID_BUTTON: { 2649 HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element); 2650 switch (token) { 2651 // read-only: form 2652 case ButtonAccessKey: { button.setAccessKey(str); return; } 2653 case ButtonDisabled: { button.setDisabled(value.toBoolean(exec)); return; } 2654 case ButtonName: { button.setName(str); return; } 2655 case ButtonTabIndex: { button.setTabIndex(value.toInt32(exec)); return; } 2656 // read-only: type 2657 case ButtonValue: { button.setValue(str); return; } 2658 } 2659 } 2660 break; 2661 case ID_LABEL: { 2662 HTMLLabelElementImpl &label = static_cast<HTMLLabelElementImpl &>(element); 2663 switch (token) { 2664 // read-only: form 2665 case LabelAccessKey: { label.setAccessKey(str); return; } 2666 case LabelHtmlFor: { label.setHtmlFor(str); return; } 2667 } 2668 } 2669 break; 2670 case ID_LEGEND: { 2671 HTMLLegendElementImpl &legend = static_cast<HTMLLegendElementImpl &>(element); 2672 switch (token) { 2673 // read-only: form 2674 case LegendAccessKey: { legend.setAccessKey(str); return; } 2675 case LegendAlign: { legend.setAlign(str); return; } 2676 } 2677 } 2678 break; 2679 case ID_UL: { 2680 HTMLUListElementImpl &uList = static_cast<HTMLUListElementImpl &>(element); 2681 switch (token) { 2682 case UListCompact: { uList.setCompact(value.toBoolean(exec)); return; } 2683 case UListType: { uList.setType(str); return; } 2684 } 2685 } 2686 break; 2687 case ID_OL: { 2688 HTMLOListElementImpl &oList = static_cast<HTMLOListElementImpl &>(element); 2689 switch (token) { 2690 case OListCompact: { oList.setCompact(value.toBoolean(exec)); return; } 2691 case OListStart: { oList.setStart(value.toInt32(exec)); return; } 2692 case OListType: { oList.setType(str); return; } 2693 } 2694 } 2695 break; 2696 case ID_DL: { 2697 HTMLDListElementImpl &dList = static_cast<HTMLDListElementImpl &>(element); 2698 switch (token) { 2699 case DListCompact: { dList.setCompact(value.toBoolean(exec)); return; } 2700 } 2701 } 2702 break; 2703 case ID_DIR: { 2704 HTMLDirectoryElementImpl &directory = static_cast<HTMLDirectoryElementImpl &>(element); 2705 switch (token) { 2706 case DirectoryCompact: { directory.setCompact(value.toBoolean(exec)); return; } 2707 } 2708 } 2709 break; 2710 case ID_MENU: { 2711 HTMLMenuElementImpl &menu = static_cast<HTMLMenuElementImpl &>(element); 2712 switch (token) { 2713 case MenuCompact: { menu.setCompact(value.toBoolean(exec)); return; } 2714 } 2715 } 2716 break; 2717 case ID_LI: { 2718 HTMLLIElementImpl &li = static_cast<HTMLLIElementImpl &>(element); 2719 switch (token) { 2720 case LIType: { li.setType(str); return; } 2721 case LIValue: { li.setValue(value.toInt32(exec)); return; } 2722 } 2723 } 2724 break; 2725 case ID_DIV: { 2726 HTMLDivElementImpl &div = static_cast<HTMLDivElementImpl &>(element); 2727 switch (token) { 2728 case DivAlign: { div.setAlign(str); return; } 2729 } 2730 } 2731 break; 2732 case ID_P: { 2733 HTMLParagraphElementImpl ¶graph = static_cast<HTMLParagraphElementImpl &>(element); 2734 switch (token) { 2735 case ParagraphAlign: { paragraph.setAlign(str); return; } 2736 } 2737 } 2738 break; 2739 case ID_H1: 2740 case ID_H2: 2741 case ID_H3: 2742 case ID_H4: 2743 case ID_H5: 2744 case ID_H6: { 2745 HTMLHeadingElementImpl &heading = static_cast<HTMLHeadingElementImpl &>(element); 2746 switch (token) { 2747 case HeadingAlign: { heading.setAlign(str); return; } 2748 } 2749 } 2750 break; 2751 case ID_BLOCKQUOTE: { 2752 HTMLBlockquoteElementImpl &blockquote = static_cast<HTMLBlockquoteElementImpl &>(element); 2753 switch (token) { 2754 case BlockQuoteCite: { blockquote.setCite(str); return; } 2755 } 2756 } 2757 break; 2758 case ID_Q: { 2759 HTMLQuoteElementImpl "e = static_cast<HTMLQuoteElementImpl &>(element); 2760 switch (token) { 2761 case QuoteCite: { quote.setCite(str); return; } 2762 } 2763 } 2764 break; 2765 case ID_PRE: { 2766 HTMLPreElementImpl &pre = static_cast<HTMLPreElementImpl &>(element); 2767 switch (token) { 2768 case PreWidth: { pre.setWidth(value.toInt32(exec)); return; } 2769 } 2770 } 2771 break; 2772 case ID_BR: { 2773 HTMLBRElementImpl &br = static_cast<HTMLBRElementImpl &>(element); 2774 switch (token) { 2775 case BRClear: { br.setClear(str); return; } 2776 } 2777 } 2778 break; 2779 case ID_BASEFONT: { 2780 HTMLBaseFontElementImpl &baseFont = static_cast<HTMLBaseFontElementImpl &>(element); 2781 switch (token) { 2782 case BaseFontColor: { baseFont.setColor(str); return; } 2783 case BaseFontFace: { baseFont.setFace(str); return; } 2784 case BaseFontSize: { baseFont.setSize(str); return; } 2785 } 2786 } 2787 break; 2788 case ID_FONT: { 2789 HTMLFontElementImpl &font = static_cast<HTMLFontElementImpl &>(element); 2790 switch (token) { 2791 case FontColor: { font.setColor(str); return; } 2792 case FontFace: { font.setFace(str); return; } 2793 case FontSize: { font.setSize(str); return; } 2794 } 2795 } 2796 break; 2797 case ID_HR: { 2798 HTMLHRElementImpl &hr = static_cast<HTMLHRElementImpl &>(element); 2799 switch (token) { 2800 case HRAlign: { hr.setAlign(str); return; } 2801 case HRNoShade: { hr.setNoShade(value.toBoolean(exec)); return; } 2802 case HRSize: { hr.setSize(str); return; } 2803 case HRWidth: { hr.setWidth(str); return; } 2804 } 2805 } 2806 break; 2807 case ID_INS: 2808 case ID_DEL: { 2809 HTMLModElementImpl &mod = static_cast<HTMLModElementImpl &>(element); 2810 switch (token) { 2811 case ModCite: { mod.setCite(str); return; } 2812 case ModDateTime: { mod.setDateTime(str); return; } 2813 } 2814 } 2815 break; 2816 case ID_A: { 2817 HTMLAnchorElementImpl &anchor = static_cast<HTMLAnchorElementImpl &>(element); 2818 switch (token) { 2819 case AnchorAccessKey: { anchor.setAccessKey(str); return; } 2820 case AnchorCharset: { anchor.setCharset(str); return; } 2821 case AnchorCoords: { anchor.setCoords(str); return; } 2822 case AnchorHref: { anchor.setHref(str); return; } 2823 case AnchorHrefLang: { anchor.setHreflang(str); return; } 2824 case AnchorName: { anchor.setName(str); return; } 2825 case AnchorRel: { anchor.setRel(str); return; } 2826 case AnchorRev: { anchor.setRev(str); return; } 2827 case AnchorShape: { anchor.setShape(str); return; } 2828 case AnchorTabIndex: { anchor.setTabIndex(value.toInt32(exec)); return; } 2829 case AnchorTarget: { anchor.setTarget(str); return; } 2830 case AnchorType: { anchor.setType(str); return; } 2831 } 2832 } 2833 break; 2834 case ID_IMG: { 2835 HTMLImageElementImpl &image = static_cast<HTMLImageElementImpl &>(element); 2836 switch (token) { 2837 case ImageName: { image.setName(str); return; } 2838 case ImageAlign: { image.setAlign(str); return; } 2839 case ImageAlt: { image.setAlt(str); return; } 2840 case ImageBorder: { image.setBorder(value.toInt32(exec)); return; } 2841 case ImageHeight: { image.setHeight(value.toInt32(exec)); return; } 2842 case ImageHspace: { image.setHspace(value.toInt32(exec)); return; } 2843 case ImageIsMap: { image.setIsMap(value.toBoolean(exec)); return; } 2844 case ImageLongDesc: { image.setLongDesc(str); return; } 2845 case ImageSrc: { image.setSrc(str); return; } 2846 case ImageUseMap: { image.setUseMap(str); return; } 2847 case ImageVspace: { image.setVspace(value.toInt32(exec)); return; } 2848 case ImageWidth: { image.setWidth(value.toInt32(exec)); return; } 2849 } 2850 } 2851 break; 2852 case ID_OBJECT: { 2853 HTMLObjectElementImpl &object = static_cast<HTMLObjectElementImpl &>(element); 2854 switch (token) { 2855 // read-only: form 2856 case ObjectCode: { object.setCode(str); return; } 2857 case ObjectAlign: { object.setAlign(str); return; } 2858 case ObjectArchive: { object.setArchive(str); return; } 2859 case ObjectBorder: { object.setBorder(str); return; } 2860 case ObjectCodeBase: { object.setCodeBase(str); return; } 2861 case ObjectCodeType: { object.setCodeType(str); return; } 2862 // read-only: ObjectContentDocument 2863 case ObjectData: { object.setData(str); return; } 2864 case ObjectDeclare: { object.setDeclare(value.toBoolean(exec)); return; } 2865 case ObjectHeight: { object.setHeight(str); return; } 2866 case ObjectHspace: { object.setHspace(str); return; } 2867 case ObjectName: { object.setName(str); return; } 2868 case ObjectStandby: { object.setStandby(str); return; } 2869 case ObjectTabIndex: { object.setTabIndex(value.toInt32(exec)); return; } 2870 case ObjectType: { object.setType(str); return; } 2871 case ObjectUseMap: { object.setUseMap(str); return; } 2872 case ObjectVspace: { object.setVspace(str); return; } 2873 case ObjectWidth: { object.setWidth(str); return; } 2874 } 2875 } 2876 break; 2877 case ID_PARAM: { 2878 HTMLParamElementImpl ¶m = static_cast<HTMLParamElementImpl &>(element); 2879 switch (token) { 2880 case ParamName: { param.setName(str); return; } 2881 case ParamType: { param.setType(str); return; } 2882 case ParamValue: { param.setValue(str); return; } 2883 case ParamValueType: { param.setValueType(str); return; } 2884 } 2885 } 2886 break; 2887 case ID_APPLET: { 2888 HTMLAppletElementImpl &applet = static_cast<HTMLAppletElementImpl &>(element); 2889 switch (token) { 2890 case AppletAlign: { applet.setAlign(str); return; } 2891 case AppletAlt: { applet.setAlt(str); return; } 2892 case AppletArchive: { applet.setArchive(str); return; } 2893 case AppletCode: { applet.setCode(str); return; } 2894 case AppletCodeBase: { applet.setCodeBase(str); return; } 2895 case AppletHeight: { applet.setHeight(str); return; } 2896 case AppletHspace: { applet.setHspace(str); return; } 2897 case AppletName: { applet.setName(str); return; } 2898 case AppletObject: { applet.setObject(str); return; } 2899 case AppletVspace: { applet.setVspace(str); return; } 2900 case AppletWidth: { applet.setWidth(str); return; } 2901 } 2902 } 2903 break; 2904 case ID_MAP: { 2905 HTMLMapElementImpl &map = static_cast<HTMLMapElementImpl &>(element); 2906 switch (token) { 2907 // read-only: areas 2908 case MapName: { map.setName(str); return; } 2909 } 2910 } 2911 break; 2912 case ID_AREA: { 2913 HTMLAreaElementImpl &area = static_cast<HTMLAreaElementImpl &>(element); 2914 switch (token) { 2915 case AreaAccessKey: { area.setAccessKey(str); return; } 2916 case AreaAlt: { area.setAlt(str); return; } 2917 case AreaCoords: { area.setCoords(str); return; } 2918 case AreaHref: { area.setHref(str); return; } 2919 case AreaNoHref: { area.setNoHref(value.toBoolean(exec)); return; } 2920 case AreaShape: { area.setShape(str); return; } 2921 case AreaTabIndex: { area.setTabIndex(value.toInt32(exec)); return; } 2922 case AreaTarget: { area.setTarget(str); return; } 2923 } 2924 } 2925 break; 2926 case ID_SCRIPT: { 2927 HTMLScriptElementImpl &script = static_cast<HTMLScriptElementImpl &>(element); 2928 switch (token) { 2929 case ScriptText: { script.setText(str); return; } 2930 case ScriptHtmlFor: { script.setHtmlFor(str); return; } 2931 case ScriptEvent: { script.setEvent(str); return; } 2932 case ScriptCharset: { script.setCharset(str); return; } 2933 case ScriptDefer: { script.setDefer(value.toBoolean(exec)); return; } 2934 case ScriptSrc: { script.setSrc(str); return; } 2935 case ScriptType: { script.setType(str); return; } 2936 } 2937 } 2938 break; 2939 case ID_TABLE: { 2940 HTMLTableElementImpl &table = static_cast<HTMLTableElementImpl &>(element); 2941 switch (token) { 2942 case TableCaption: { table.setCaption(toHTMLTableCaptionElement(value)); return; } 2943 case TableTHead: { table.setTHead(toHTMLTableSectionElement(value)); return; } 2944 case TableTFoot: { table.setTFoot(toHTMLTableSectionElement(value)); return; } 2945 // read-only: rows 2946 // read-only: tbodies 2947 case TableAlign: { table.setAlign(str); return; } 2948 case TableBgColor: { table.setBgColor(str); return; } 2949 case TableBorder: { table.setBorder(str); return; } 2950 case TableCellPadding: { table.setCellPadding(str); return; } 2951 case TableCellSpacing: { table.setCellSpacing(str); return; } 2952 case TableFrame: { table.setFrame(str); return; } 2953 case TableRules: { table.setRules(str); return; } 2954 case TableSummary: { table.setSummary(str); return; } 2955 case TableWidth: { table.setWidth(str); return; } 2956 } 2957 } 2958 break; 2959 case ID_CAPTION: { 2960 HTMLTableCaptionElementImpl &tableCaption = static_cast<HTMLTableCaptionElementImpl &>(element); 2961 switch (token) { 2962 case TableAlign: { tableCaption.setAlign(str); return; } 2963 } 2964 } 2965 break; 2966 case ID_COL: { 2967 HTMLTableColElementImpl &tableCol = static_cast<HTMLTableColElementImpl &>(element); 2968 switch (token) { 2969 case TableColAlign: { tableCol.setAlign(str); return; } 2970 case TableColCh: { tableCol.setCh(str); return; } 2971 case TableColChOff: { tableCol.setChOff(str); return; } 2972 case TableColSpan: { tableCol.setSpan(value.toInt32(exec)); return; } 2973 case TableColVAlign: { tableCol.setVAlign(str); return; } 2974 case TableColWidth: { tableCol.setWidth(str); return; } 2975 } 2976 } 2977 break; 2978 case ID_THEAD: 2979 case ID_TBODY: 2980 case ID_TFOOT: { 2981 HTMLTableSectionElementImpl &tableSection = static_cast<HTMLTableSectionElementImpl &>(element); 2982 switch (token) { 2983 case TableSectionAlign: { tableSection.setAlign(str); return; } 2984 case TableSectionCh: { tableSection.setCh(str); return; } 2985 case TableSectionChOff: { tableSection.setChOff(str); return; } 2986 case TableSectionVAlign: { tableSection.setVAlign(str); return; } 2987 // read-only: rows 2988 } 2989 } 2990 break; 2991 case ID_TR: { 2992 HTMLTableRowElementImpl &tableRow = static_cast<HTMLTableRowElementImpl &>(element); 2993 switch (token) { 2994 // read-only: rowIndex 2995 // read-only: sectionRowIndex 2996 // read-only: cells 2997 case TableRowAlign: { tableRow.setAlign(str); return; } 2998 case TableRowBgColor: { tableRow.setBgColor(str); return; } 2999 case TableRowCh: { tableRow.setCh(str); return; } 3000 case TableRowChOff: { tableRow.setChOff(str); return; } 3001 case TableRowVAlign: { tableRow.setVAlign(str); return; } 3002 } 3003 } 3004 break; 3005 case ID_TH: 3006 case ID_TD: { 3007 HTMLTableCellElementImpl &tableCell = static_cast<HTMLTableCellElementImpl &>(element); 3008 switch (token) { 3009 // read-only: cellIndex 3010 case TableCellAbbr: { tableCell.setAbbr(str); return; } 3011 case TableCellAlign: { tableCell.setAlign(str); return; } 3012 case TableCellAxis: { tableCell.setAxis(str); return; } 3013 case TableCellBgColor: { tableCell.setBgColor(str); return; } 3014 case TableCellCh: { tableCell.setCh(str); return; } 3015 case TableCellChOff: { tableCell.setChOff(str); return; } 3016 case TableCellColSpan: { tableCell.setColSpan(value.toInt32(exec)); return; } 3017 case TableCellHeaders: { tableCell.setHeaders(str); return; } 3018 case TableCellHeight: { tableCell.setHeight(str); return; } 3019 case TableCellNoWrap: { tableCell.setNoWrap(value.toBoolean(exec)); return; } 3020 case TableCellRowSpan: { tableCell.setRowSpan(value.toInt32(exec)); return; } 3021 case TableCellScope: { tableCell.setScope(str); return; } 3022 case TableCellVAlign: { tableCell.setVAlign(str); return; } 3023 case TableCellWidth: { tableCell.setWidth(str); return; } 3024 } 3025 } 3026 break; 3027 case ID_FRAMESET: { 3028 HTMLFrameSetElementImpl &frameSet = static_cast<HTMLFrameSetElementImpl &>(element); 3029 switch (token) { 3030 case FrameSetCols: { frameSet.setCols(str); return; } 3031 case FrameSetRows: { frameSet.setRows(str); return; } 3032 } 3033 } 3034 break; 3035 case ID_FRAME: { 3036 HTMLFrameElementImpl &frameElement = static_cast<HTMLFrameElementImpl &>(element); 3037 switch (token) { 3038 // read-only: FrameContentDocument: 3039 case FrameFrameBorder: { frameElement.setFrameBorder(str); return; } 3040 case FrameLongDesc: { frameElement.setLongDesc(str); return; } 3041 case FrameMarginHeight: { frameElement.setMarginHeight(str); return; } 3042 case FrameMarginWidth: { frameElement.setMarginWidth(str); return; } 3043 case FrameName: { frameElement.setName(str); return; } 3044 case FrameNoResize: { frameElement.setNoResize(value.toBoolean(exec)); return; } 3045 case FrameScrolling: { frameElement.setScrolling(str); return; } 3046 case FrameSrc: { frameElement.setSrc(str); return; } 3047 case FrameLocation: { frameElement.setLocation(str); return; } 3048 } 3049 } 3050 break; 3051 case ID_IFRAME: { 3052 HTMLIFrameElementImpl &iFrame = static_cast<HTMLIFrameElementImpl &>(element); 3053 switch (token) { 3054 case IFrameAlign: { iFrame.setAlign(str); return; } 3055 // read-only: IFrameContentDocument 3056 case IFrameFrameBorder: { iFrame.setFrameBorder(str); return; } 3057 case IFrameHeight: { iFrame.setHeight(str); return; } 3058 case IFrameLongDesc: { iFrame.setLongDesc(str); return; } 3059 case IFrameMarginHeight: { iFrame.setMarginHeight(str); return; } 3060 case IFrameMarginWidth: { iFrame.setMarginWidth(str); return; } 3061 case IFrameName: { iFrame.setName(str); return; } 3062 case IFrameScrolling: { iFrame.setScrolling(str); return; } 3063 case IFrameSrc: { iFrame.setSrc(str); return; } 3064 case IFrameWidth: { iFrame.setWidth(str); return; } 3065 } 3066 break; 3067 } 3068 } 3069 3070 // generic properties 3071 switch (token) { 3072 case ElementId: 3073 element.setId(str); 3074 return; 3075 case ElementTitle: 3076 element.setTitle(str); 3077 return; 3078 case ElementLang: 3079 element.setLang(str); 3080 return; 3081 case ElementDir: 3082 element.setDir(str); 3083 return; 3084 case ElementClassName: 3085 element.setClassName(str); 3086 return; 3087 case ElementInnerHTML: 3088 element.setInnerHTML(str, exception); 3089 return; 3090 case ElementInnerText: 3091 element.setInnerText(str, exception); 3092 return; 3093 case ElementOuterHTML: 3094 element.setOuterHTML(str, exception); 3095 return; 3096 case ElementOuterText: 3097 element.setOuterText(str, exception); 3098 return; 3099 case ElementContentEditable: 3100 element.setContentEditable(str); 3101 return; 3102 default: 3103 kdWarning() << "KJS::HTMLElement::putValue unhandled token " << token << " thisTag=" << element.tagName().string() << " str=" << str.string() << endl; 3104 } 2693 } 2694 // read-only: form 2695 // read-only: options 2696 case SelectDisabled: { select.setDisabled(value.toBoolean(exec)); return; } 2697 case SelectMultiple: { select.setMultiple(value.toBoolean(exec)); return; } 2698 case SelectName: { select.setName(str); return; } 2699 case SelectSize: { select.setSize(value.toInt32(exec)); return; } 2700 case SelectTabIndex: { select.setTabIndex(value.toInt32(exec)); return; } 2701 } 2702 } 2703 2704 void HTMLElement::optGroupSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2705 { 2706 HTMLOptGroupElementImpl& optgroup = *static_cast<HTMLOptGroupElementImpl*>(impl()); 2707 switch (token) { 2708 case OptGroupDisabled: { optgroup.setDisabled(value.toBoolean(exec)); return; } 2709 case OptGroupLabel: { optgroup.setLabel(str); return; } 2710 } 2711 } 2712 2713 void HTMLElement::optionSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2714 { 2715 DOMExceptionTranslator exception(exec); 2716 HTMLOptionElementImpl& option = *static_cast<HTMLOptionElementImpl*>(impl()); 2717 switch (token) { 2718 // read-only: form 2719 case OptionDefaultSelected: { option.setDefaultSelected(value.toBoolean(exec)); return; } 2720 case OptionText: { option.setText(str, exception); return; } 2721 // read-only: index 2722 case OptionDisabled: { option.setDisabled(value.toBoolean(exec)); return; } 2723 case OptionLabel: { option.setLabel(str); return; } 2724 case OptionSelected: { option.setSelected(value.toBoolean(exec)); return; } 2725 case OptionValue: { option.setValue(str); return; } 2726 } 2727 } 2728 2729 void HTMLElement::inputSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2730 { 2731 HTMLInputElementImpl& input = *static_cast<HTMLInputElementImpl*>(impl()); 2732 switch (token) { 2733 case InputDefaultValue: { input.setDefaultValue(str); return; } 2734 case InputDefaultChecked: { input.setDefaultChecked(value.toBoolean(exec)); return; } 2735 // read-only: form 2736 case InputAccept: { input.setAccept(str); return; } 2737 case InputAccessKey: { input.setAccessKey(str); return; } 2738 case InputAlign: { input.setAlign(str); return; } 2739 case InputAlt: { input.setAlt(str); return; } 2740 case InputChecked: { input.setChecked(value.toBoolean(exec)); return; } 2741 case InputDisabled: { input.setDisabled(value.toBoolean(exec)); return; } 2742 case InputMaxLength: { input.setMaxLength(value.toInt32(exec)); return; } 2743 case InputName: { input.setName(str); return; } 2744 case InputReadOnly: { input.setReadOnly(value.toBoolean(exec)); return; } 2745 case InputSize: { input.setSize(str); return; } 2746 case InputSelectionStart: { input.setSelectionStart(value.toInt32(exec)); return; } 2747 case InputSelectionEnd: { input.setSelectionEnd(value.toInt32(exec)); return; } 2748 case InputSrc: { input.setSrc(str); return; } 2749 case InputTabIndex: { input.setTabIndex(value.toInt32(exec)); return; } 2750 case InputType: { input.setType(str); return; } 2751 case InputUseMap: { input.setUseMap(str); return; } 2752 case InputValue: { input.setValue(str); return; } 2753 } 2754 } 2755 2756 void HTMLElement::textAreaSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2757 { 2758 HTMLTextAreaElementImpl& textarea = *static_cast<HTMLTextAreaElementImpl*>(impl()); 2759 switch (token) { 2760 case TextAreaDefaultValue: { textarea.setDefaultValue(str); return; } 2761 // read-only: form 2762 case TextAreaAccessKey: { textarea.setAccessKey(str); return; } 2763 case TextAreaCols: { textarea.setCols(value.toInt32(exec)); return; } 2764 case TextAreaDisabled: { textarea.setDisabled(value.toBoolean(exec)); return; } 2765 case TextAreaName: { textarea.setName(str); return; } 2766 case TextAreaReadOnly: { textarea.setReadOnly(value.toBoolean(exec)); return; } 2767 case TextAreaRows: { textarea.setRows(value.toInt32(exec)); return; } 2768 case TextAreaSelectionStart: { textarea.setSelectionStart(value.toInt32(exec)); return; } 2769 case TextAreaSelectionEnd: { textarea.setSelectionEnd(value.toInt32(exec)); return; } 2770 case TextAreaTabIndex: { textarea.setTabIndex(value.toInt32(exec)); return; } 2771 // read-only: type 2772 case TextAreaValue: { textarea.setValue(str); return; } 2773 } 2774 } 2775 2776 void HTMLElement::buttonSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2777 { 2778 HTMLButtonElementImpl& button = *static_cast<HTMLButtonElementImpl*>(impl()); 2779 switch (token) { 2780 // read-only: form 2781 case ButtonAccessKey: { button.setAccessKey(str); return; } 2782 case ButtonDisabled: { button.setDisabled(value.toBoolean(exec)); return; } 2783 case ButtonName: { button.setName(str); return; } 2784 case ButtonTabIndex: { button.setTabIndex(value.toInt32(exec)); return; } 2785 // read-only: type 2786 case ButtonValue: { button.setValue(str); return; } 2787 } 2788 } 2789 2790 void HTMLElement::labelSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2791 { 2792 HTMLLabelElementImpl& label = *static_cast<HTMLLabelElementImpl*>(impl()); 2793 switch (token) { 2794 // read-only: form 2795 case LabelAccessKey: { label.setAccessKey(str); return; } 2796 case LabelHtmlFor: { label.setHtmlFor(str); return; } 2797 } 2798 } 2799 2800 void HTMLElement::fieldSetSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2801 { 2802 } 2803 2804 void HTMLElement::legendSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2805 { 2806 HTMLLegendElementImpl& legend = *static_cast<HTMLLegendElementImpl*>(impl()); 2807 switch (token) { 2808 // read-only: form 2809 case LegendAccessKey: { legend.setAccessKey(str); return; } 2810 case LegendAlign: { legend.setAlign(str); return; } 2811 } 2812 } 2813 2814 void HTMLElement::uListSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2815 { 2816 HTMLUListElementImpl& uList = *static_cast<HTMLUListElementImpl*>(impl()); 2817 switch (token) { 2818 case UListCompact: { uList.setCompact(value.toBoolean(exec)); return; } 2819 case UListType: { uList.setType(str); return; } 2820 } 2821 } 2822 2823 void HTMLElement::oListSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2824 { 2825 HTMLOListElementImpl& oList = *static_cast<HTMLOListElementImpl*>(impl()); 2826 switch (token) { 2827 case OListCompact: { oList.setCompact(value.toBoolean(exec)); return; } 2828 case OListStart: { oList.setStart(value.toInt32(exec)); return; } 2829 case OListType: { oList.setType(str); return; } 2830 } 2831 } 2832 2833 void HTMLElement::dListSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2834 { 2835 HTMLDListElementImpl& dList = *static_cast<HTMLDListElementImpl*>(impl()); 2836 if (token == DListCompact) 2837 dList.setCompact(value.toBoolean(exec)); 2838 } 2839 2840 void HTMLElement::dirSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2841 { 2842 HTMLDirectoryElementImpl& directory = *static_cast<HTMLDirectoryElementImpl*>(impl()); 2843 if (token == DirectoryCompact) 2844 directory.setCompact(value.toBoolean(exec)); 2845 } 2846 2847 void HTMLElement::menuSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2848 { 2849 HTMLMenuElementImpl& menu = *static_cast<HTMLMenuElementImpl*>(impl()); 2850 if (token == MenuCompact) 2851 menu.setCompact(value.toBoolean(exec)); 2852 } 2853 2854 void HTMLElement::liSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2855 { 2856 HTMLLIElementImpl& li = *static_cast<HTMLLIElementImpl*>(impl()); 2857 switch (token) { 2858 case LIType: { li.setType(str); return; } 2859 case LIValue: { li.setValue(value.toInt32(exec)); return; } 2860 } 2861 } 2862 2863 void HTMLElement::divSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2864 { 2865 HTMLDivElementImpl& div = *static_cast<HTMLDivElementImpl*>(impl()); 2866 if (token == DivAlign) 2867 div.setAlign(str); 2868 } 2869 2870 void HTMLElement::paragraphSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2871 { 2872 HTMLParagraphElementImpl& paragraph = *static_cast<HTMLParagraphElementImpl*>(impl()); 2873 if (token == ParagraphAlign) 2874 paragraph.setAlign(str); 2875 } 2876 2877 void HTMLElement::headingSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2878 { 2879 HTMLHeadingElementImpl& heading = *static_cast<HTMLHeadingElementImpl*>(impl()); 2880 if (token == HeadingAlign) 2881 heading.setAlign(str); 2882 } 2883 2884 void HTMLElement::blockQuoteSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2885 { 2886 HTMLBlockquoteElementImpl& blockQuote = *static_cast<HTMLBlockquoteElementImpl*>(impl()); 2887 if (token == BlockQuoteCite) 2888 blockQuote.setCite(str); 2889 } 2890 2891 void HTMLElement::quoteSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2892 { 2893 HTMLQuoteElementImpl& quote = *static_cast<HTMLQuoteElementImpl*>(impl()); 2894 if (token == QuoteCite) 2895 quote.setCite(str); 2896 } 2897 2898 void HTMLElement::preSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2899 { 2900 // FIXME: Add support for 'wrap' when white-space: pre-wrap is implemented. 2901 HTMLPreElementImpl& pre = *static_cast<HTMLPreElementImpl*>(impl()); 2902 if (token == PreWidth) 2903 pre.setWidth(value.toInt32(exec)); 2904 } 2905 2906 void HTMLElement::brSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2907 { 2908 HTMLBRElementImpl& br = *static_cast<HTMLBRElementImpl*>(impl()); 2909 if (token == BRClear) 2910 br.setClear(str); 2911 } 2912 2913 void HTMLElement::baseFontSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2914 { 2915 HTMLBaseFontElementImpl& baseFont = *static_cast<HTMLBaseFontElementImpl*>(impl()); 2916 switch (token) { 2917 case BaseFontColor: { baseFont.setColor(str); return; } 2918 case BaseFontFace: { baseFont.setFace(str); return; } 2919 case BaseFontSize: { baseFont.setSize(str); return; } 2920 } 2921 } 2922 2923 void HTMLElement::fontSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2924 { 2925 HTMLFontElementImpl& font = *static_cast<HTMLFontElementImpl*>(impl()); 2926 switch (token) { 2927 case FontColor: { font.setColor(str); return; } 2928 case FontFace: { font.setFace(str); return; } 2929 case FontSize: { font.setSize(str); return; } 2930 } 2931 } 2932 2933 void HTMLElement::hrSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2934 { 2935 HTMLHRElementImpl& hr = *static_cast<HTMLHRElementImpl*>(impl()); 2936 switch (token) { 2937 case HRAlign: { hr.setAlign(str); return; } 2938 case HRNoShade: { hr.setNoShade(value.toBoolean(exec)); return; } 2939 case HRSize: { hr.setSize(str); return; } 2940 case HRWidth: { hr.setWidth(str); return; } 2941 } 2942 } 2943 2944 void HTMLElement::modSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2945 { 2946 HTMLModElementImpl& mod = *static_cast<HTMLModElementImpl*>(impl()); 2947 switch (token) { 2948 case ModCite: { mod.setCite(str); return; } 2949 case ModDateTime: { mod.setDateTime(str); return; } 2950 } 2951 } 2952 2953 void HTMLElement::anchorSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2954 { 2955 HTMLAnchorElementImpl& anchor = *static_cast<HTMLAnchorElementImpl*>(impl()); 2956 switch (token) { 2957 case AnchorAccessKey: { anchor.setAccessKey(str); return; } 2958 case AnchorCharset: { anchor.setCharset(str); return; } 2959 case AnchorCoords: { anchor.setCoords(str); return; } 2960 case AnchorHref: { anchor.setHref(str); return; } 2961 case AnchorHrefLang: { anchor.setHreflang(str); return; } 2962 case AnchorName: { anchor.setName(str); return; } 2963 case AnchorRel: { anchor.setRel(str); return; } 2964 case AnchorRev: { anchor.setRev(str); return; } 2965 case AnchorShape: { anchor.setShape(str); return; } 2966 case AnchorTabIndex: { anchor.setTabIndex(value.toInt32(exec)); return; } 2967 case AnchorTarget: { anchor.setTarget(str); return; } 2968 case AnchorType: { anchor.setType(str); return; } 2969 } 2970 } 2971 2972 void HTMLElement::imageSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2973 { 2974 HTMLImageElementImpl& image = *static_cast<HTMLImageElementImpl*>(impl()); 2975 switch (token) { 2976 case ImageName: { image.setName(str); return; } 2977 case ImageAlign: { image.setAlign(str); return; } 2978 case ImageAlt: { image.setAlt(str); return; } 2979 case ImageBorder: { image.setBorder(value.toInt32(exec)); return; } 2980 case ImageHeight: { image.setHeight(value.toInt32(exec)); return; } 2981 case ImageHspace: { image.setHspace(value.toInt32(exec)); return; } 2982 case ImageIsMap: { image.setIsMap(value.toBoolean(exec)); return; } 2983 case ImageLongDesc: { image.setLongDesc(str); return; } 2984 case ImageSrc: { image.setSrc(str); return; } 2985 case ImageUseMap: { image.setUseMap(str); return; } 2986 case ImageVspace: { image.setVspace(value.toInt32(exec)); return; } 2987 case ImageWidth: { image.setWidth(value.toInt32(exec)); return; } 2988 } 2989 } 2990 2991 void HTMLElement::objectSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 2992 { 2993 HTMLObjectElementImpl& object = *static_cast<HTMLObjectElementImpl*>(impl()); 2994 switch (token) { 2995 // read-only: form 2996 case ObjectCode: { object.setCode(str); return; } 2997 case ObjectAlign: { object.setAlign(str); return; } 2998 case ObjectArchive: { object.setArchive(str); return; } 2999 case ObjectBorder: { object.setBorder(str); return; } 3000 case ObjectCodeBase: { object.setCodeBase(str); return; } 3001 case ObjectCodeType: { object.setCodeType(str); return; } 3002 // read-only: ObjectContentDocument 3003 case ObjectData: { object.setData(str); return; } 3004 case ObjectDeclare: { object.setDeclare(value.toBoolean(exec)); return; } 3005 case ObjectHeight: { object.setHeight(str); return; } 3006 case ObjectHspace: { object.setHspace(str); return; } 3007 case ObjectName: { object.setName(str); return; } 3008 case ObjectStandby: { object.setStandby(str); return; } 3009 case ObjectTabIndex: { object.setTabIndex(value.toInt32(exec)); return; } 3010 case ObjectType: { object.setType(str); return; } 3011 case ObjectUseMap: { object.setUseMap(str); return; } 3012 case ObjectVspace: { object.setVspace(str); return; } 3013 case ObjectWidth: { object.setWidth(str); return; } 3014 } 3015 } 3016 3017 void HTMLElement::paramSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3018 { 3019 HTMLParamElementImpl& param = *static_cast<HTMLParamElementImpl*>(impl()); 3020 switch (token) { 3021 case ParamName: { param.setName(str); return; } 3022 case ParamType: { param.setType(str); return; } 3023 case ParamValue: { param.setValue(str); return; } 3024 case ParamValueType: { param.setValueType(str); return; } 3025 } 3026 } 3027 3028 void HTMLElement::appletSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3029 { 3030 HTMLAppletElementImpl& applet = *static_cast<HTMLAppletElementImpl*>(impl()); 3031 switch (token) { 3032 case AppletAlign: { applet.setAlign(str); return; } 3033 case AppletAlt: { applet.setAlt(str); return; } 3034 case AppletArchive: { applet.setArchive(str); return; } 3035 case AppletCode: { applet.setCode(str); return; } 3036 case AppletCodeBase: { applet.setCodeBase(str); return; } 3037 case AppletHeight: { applet.setHeight(str); return; } 3038 case AppletHspace: { applet.setHspace(str); return; } 3039 case AppletName: { applet.setName(str); return; } 3040 case AppletObject: { applet.setObject(str); return; } 3041 case AppletVspace: { applet.setVspace(str); return; } 3042 case AppletWidth: { applet.setWidth(str); return; } 3043 } 3044 } 3045 3046 void HTMLElement::mapSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3047 { 3048 HTMLMapElementImpl& map = *static_cast<HTMLMapElementImpl*>(impl()); 3049 if (token == MapName) 3050 // read-only: areas 3051 map.setName(str); 3052 } 3053 3054 void HTMLElement::areaSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3055 { 3056 HTMLAreaElementImpl& area = *static_cast<HTMLAreaElementImpl*>(impl()); 3057 switch (token) { 3058 case AreaAccessKey: { area.setAccessKey(str); return; } 3059 case AreaAlt: { area.setAlt(str); return; } 3060 case AreaCoords: { area.setCoords(str); return; } 3061 case AreaHref: { area.setHref(str); return; } 3062 case AreaNoHref: { area.setNoHref(value.toBoolean(exec)); return; } 3063 case AreaShape: { area.setShape(str); return; } 3064 case AreaTabIndex: { area.setTabIndex(value.toInt32(exec)); return; } 3065 case AreaTarget: { area.setTarget(str); return; } 3066 } 3067 } 3068 3069 void HTMLElement::scriptSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3070 { 3071 HTMLScriptElementImpl& script = *static_cast<HTMLScriptElementImpl*>(impl()); 3072 switch (token) { 3073 case ScriptText: { script.setText(str); return; } 3074 case ScriptHtmlFor: { script.setHtmlFor(str); return; } 3075 case ScriptEvent: { script.setEvent(str); return; } 3076 case ScriptCharset: { script.setCharset(str); return; } 3077 case ScriptDefer: { script.setDefer(value.toBoolean(exec)); return; } 3078 case ScriptSrc: { script.setSrc(str); return; } 3079 case ScriptType: { script.setType(str); return; } 3080 } 3081 } 3082 3083 void HTMLElement::tableSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3084 { 3085 HTMLTableElementImpl& table = *static_cast<HTMLTableElementImpl*>(impl()); 3086 switch (token) { 3087 case TableCaption: { table.setCaption(toHTMLTableCaptionElement(value)); return; } 3088 case TableTHead: { table.setTHead(toHTMLTableSectionElement(value)); return; } 3089 case TableTFoot: { table.setTFoot(toHTMLTableSectionElement(value)); return; } 3090 // read-only: rows 3091 // read-only: tbodies 3092 case TableAlign: { table.setAlign(str); return; } 3093 case TableBgColor: { table.setBgColor(str); return; } 3094 case TableBorder: { table.setBorder(str); return; } 3095 case TableCellPadding: { table.setCellPadding(str); return; } 3096 case TableCellSpacing: { table.setCellSpacing(str); return; } 3097 case TableFrame: { table.setFrame(str); return; } 3098 case TableRules: { table.setRules(str); return; } 3099 case TableSummary: { table.setSummary(str); return; } 3100 case TableWidth: { table.setWidth(str); return; } 3101 } 3102 } 3103 3104 void HTMLElement::tableCaptionSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3105 { 3106 HTMLTableCaptionElementImpl& tableCaption = *static_cast<HTMLTableCaptionElementImpl*>(impl()); 3107 if (token == TableCaptionAlign) 3108 tableCaption.setAlign(str); 3109 } 3110 3111 void HTMLElement::tableColSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3112 { 3113 HTMLTableColElementImpl& tableCol = *static_cast<HTMLTableColElementImpl*>(impl()); 3114 switch (token) { 3115 case TableColAlign: { tableCol.setAlign(str); return; } 3116 case TableColCh: { tableCol.setCh(str); return; } 3117 case TableColChOff: { tableCol.setChOff(str); return; } 3118 case TableColSpan: { tableCol.setSpan(value.toInt32(exec)); return; } 3119 case TableColVAlign: { tableCol.setVAlign(str); return; } 3120 case TableColWidth: { tableCol.setWidth(str); return; } 3121 } 3122 } 3123 3124 void HTMLElement::tableSectionSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3125 { 3126 HTMLTableSectionElementImpl& tableSection = *static_cast<HTMLTableSectionElementImpl*>(impl()); 3127 switch (token) { 3128 case TableSectionAlign: { tableSection.setAlign(str); return; } 3129 case TableSectionCh: { tableSection.setCh(str); return; } 3130 case TableSectionChOff: { tableSection.setChOff(str); return; } 3131 case TableSectionVAlign: { tableSection.setVAlign(str); return; } 3132 // read-only: rows 3133 } 3134 } 3135 3136 void HTMLElement::tableRowSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3137 { 3138 HTMLTableRowElementImpl& tableRow = *static_cast<HTMLTableRowElementImpl*>(impl()); 3139 switch (token) { 3140 // read-only: rowIndex 3141 // read-only: sectionRowIndex 3142 // read-only: cells 3143 case TableRowAlign: { tableRow.setAlign(str); return; } 3144 case TableRowBgColor: { tableRow.setBgColor(str); return; } 3145 case TableRowCh: { tableRow.setCh(str); return; } 3146 case TableRowChOff: { tableRow.setChOff(str); return; } 3147 case TableRowVAlign: { tableRow.setVAlign(str); return; } 3148 } 3149 } 3150 3151 void HTMLElement::tableCellSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3152 { 3153 HTMLTableCellElementImpl& tableCell = *static_cast<HTMLTableCellElementImpl*>(impl()); 3154 switch (token) { 3155 // read-only: cellIndex 3156 case TableCellAbbr: { tableCell.setAbbr(str); return; } 3157 case TableCellAlign: { tableCell.setAlign(str); return; } 3158 case TableCellAxis: { tableCell.setAxis(str); return; } 3159 case TableCellBgColor: { tableCell.setBgColor(str); return; } 3160 case TableCellCh: { tableCell.setCh(str); return; } 3161 case TableCellChOff: { tableCell.setChOff(str); return; } 3162 case TableCellColSpan: { tableCell.setColSpan(value.toInt32(exec)); return; } 3163 case TableCellHeaders: { tableCell.setHeaders(str); return; } 3164 case TableCellHeight: { tableCell.setHeight(str); return; } 3165 case TableCellNoWrap: { tableCell.setNoWrap(value.toBoolean(exec)); return; } 3166 case TableCellRowSpan: { tableCell.setRowSpan(value.toInt32(exec)); return; } 3167 case TableCellScope: { tableCell.setScope(str); return; } 3168 case TableCellVAlign: { tableCell.setVAlign(str); return; } 3169 case TableCellWidth: { tableCell.setWidth(str); return; } 3170 } 3171 } 3172 3173 void HTMLElement::frameSetSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3174 { 3175 HTMLFrameSetElementImpl& frameSet = *static_cast<HTMLFrameSetElementImpl*>(impl()); 3176 switch (token) { 3177 case FrameSetCols: { frameSet.setCols(str); return; } 3178 case FrameSetRows: { frameSet.setRows(str); return; } 3179 } 3180 } 3181 3182 void HTMLElement::frameSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3183 { 3184 HTMLFrameElementImpl& frameElement = *static_cast<HTMLFrameElementImpl*>(impl()); 3185 switch (token) { 3186 // read-only: FrameContentDocument: 3187 case FrameFrameBorder: { frameElement.setFrameBorder(str); return; } 3188 case FrameLongDesc: { frameElement.setLongDesc(str); return; } 3189 case FrameMarginHeight: { frameElement.setMarginHeight(str); return; } 3190 case FrameMarginWidth: { frameElement.setMarginWidth(str); return; } 3191 case FrameName: { frameElement.setName(str); return; } 3192 case FrameNoResize: { frameElement.setNoResize(value.toBoolean(exec)); return; } 3193 case FrameScrolling: { frameElement.setScrolling(str); return; } 3194 case FrameSrc: { frameElement.setSrc(str); return; } 3195 case FrameLocation: { frameElement.setLocation(str); return; } 3196 } 3197 } 3198 3199 void HTMLElement::iFrameSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3200 { 3201 HTMLIFrameElementImpl& iFrame = *static_cast<HTMLIFrameElementImpl*>(impl()); 3202 switch (token) { 3203 case IFrameAlign: { iFrame.setAlign(str); return; } 3204 // read-only: IFrameContentDocument 3205 case IFrameFrameBorder: { iFrame.setFrameBorder(str); return; } 3206 case IFrameHeight: { iFrame.setHeight(str); return; } 3207 case IFrameLongDesc: { iFrame.setLongDesc(str); return; } 3208 case IFrameMarginHeight: { iFrame.setMarginHeight(str); return; } 3209 case IFrameMarginWidth: { iFrame.setMarginWidth(str); return; } 3210 case IFrameName: { iFrame.setName(str); return; } 3211 case IFrameScrolling: { iFrame.setScrolling(str); return; } 3212 case IFrameSrc: { iFrame.setSrc(str); return; } 3213 case IFrameWidth: { iFrame.setWidth(str); return; } 3214 } 3215 } 3216 3217 void HTMLElement::marqueeSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str) 3218 { 3219 // FIXME: Find out what WinIE supports and implement it. 3220 } 3221 3222 void HTMLElement::putValue(ExecState *exec, int token, const Value& value, int) 3223 { 3224 DOMExceptionTranslator exception(exec); 3225 DOM::DOMString str = value.isA(NullType) ? DOM::DOMString() : value.toString(exec).string(); 3226 3227 // Check our set of generic properties first. 3228 HTMLElementImpl &element = *static_cast<HTMLElementImpl *>(impl()); 3229 switch (token) { 3230 case ElementId: 3231 element.setId(str); 3232 return; 3233 case ElementTitle: 3234 element.setTitle(str); 3235 return; 3236 case ElementLang: 3237 element.setLang(str); 3238 return; 3239 case ElementDir: 3240 element.setDir(str); 3241 return; 3242 case ElementClassName: 3243 element.setClassName(str); 3244 return; 3245 case ElementInnerHTML: 3246 element.setInnerHTML(str, exception); 3247 return; 3248 case ElementInnerText: 3249 element.setInnerText(str, exception); 3250 return; 3251 case ElementOuterHTML: 3252 element.setOuterHTML(str, exception); 3253 return; 3254 case ElementOuterText: 3255 element.setOuterText(str, exception); 3256 return; 3257 case ElementContentEditable: 3258 element.setContentEditable(str); 3259 return; 3260 } 3261 3262 // Now check for properties that apply to a specific element type. 3263 const Accessors* info = getSetInfo(); 3264 if (info && info->m_setter) 3265 return (this->*(info->m_setter))(exec, token, value, str); 3105 3266 } 3106 3267 … … 3114 3275 HTMLTableCaptionElementImpl *toHTMLTableCaptionElement(ValueImp *val) 3115 3276 { 3116 if (HTMLElementImpl *e = toHTMLElement(val)) 3117 switch (e->id()) { 3118 case ID_CAPTION: 3119 return static_cast<HTMLTableCaptionElementImpl *>(e); 3120 } 3277 HTMLElementImpl *e = toHTMLElement(val); 3278 if (e && e->hasTagName(HTMLNames::caption())) 3279 return static_cast<HTMLTableCaptionElementImpl *>(e); 3121 3280 return 0; 3122 3281 } … … 3124 3283 HTMLTableSectionElementImpl *toHTMLTableSectionElement(ValueImp *val) 3125 3284 { 3126 if (HTMLElementImpl *e = toHTMLElement(val)) 3127 switch (e->id()) { 3128 case ID_THEAD: 3129 case ID_TBODY: 3130 case ID_TFOOT: 3131 return static_cast<HTMLTableSectionElementImpl *>(e); 3132 } 3285 HTMLElementImpl *e = toHTMLElement(val); 3286 if (e && (e->hasTagName(HTMLNames::thead()) || e->hasTagName(HTMLNames::tbody()) || e->hasTagName(HTMLNames::tfoot()))) 3287 return static_cast<HTMLTableSectionElementImpl *>(e); 3133 3288 return 0; 3134 3289 } … … 3179 3334 // NON-STANDARD options.selectedIndex 3180 3335 NodeImpl *option = collection.item(0); 3181 if (option-> id() == ID_OPTION) {3336 if (option->hasTagName(HTMLNames::option())) { 3182 3337 NodeImpl *select = option; 3183 3338 while ((select = select->parentNode())) 3184 if (select-> id() == ID_SELECT)3339 if (select->hasTagName(HTMLNames::select())) 3185 3340 return Number(static_cast<HTMLSelectElementImpl *>(select)->selectedIndex()); 3186 3341 } … … 3370 3525 // is v an option element ? 3371 3526 NodeImpl *option = toNode(value); 3372 if (!option || option->id() != ID_OPTION)3527 if (!option || !option->hasTagName(HTMLNames::option())) 3373 3528 return; 3374 3529 -
trunk/WebCore/khtml/ecma/kjs_html.h
r9582 r9639 85 85 caption_info, col_info, tablesection_info, tr_info, 86 86 tablecell_info, frameSet_info, frame_info, iFrame_info, marquee_info; 87 88 // FIXME: Might make sense to combine this with ClassInfo some day. 89 typedef Value (HTMLElement::*GetterFunction)(ExecState *exec, int token) const; 90 typedef void (HTMLElement::*SetterFunction)(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 91 struct Accessors { GetterFunction m_getter; SetterFunction m_setter; }; 92 const Accessors* getSetInfo() const; 93 static const Accessors html_accessors, head_accessors, link_accessors, title_accessors, 94 meta_accessors, base_accessors, isIndex_accessors, style_accessors, body_accessors, form_accessors, 95 select_accessors, optGroup_accessors, option_accessors, input_accessors, textArea_accessors, 96 button_accessors, label_accessors, fieldSet_accessors, legend_accessors, ul_accessors, ol_accessors, 97 dl_accessors, dir_accessors, menu_accessors, li_accessors, div_accessors, p_accessors, heading_accessors, 98 blockQuote_accessors, q_accessors, pre_accessors, br_accessors, baseFont_accessors, font_accessors, 99 hr_accessors, mod_accessors, a_accessors, canvas_accessors, img_accessors, object_accessors, param_accessors, 100 applet_accessors, map_accessors, area_accessors, script_accessors, table_accessors, 101 caption_accessors, col_accessors, tablesection_accessors, tr_accessors, 102 tablecell_accessors, frameSet_accessors, frame_accessors, iFrame_accessors, marquee_accessors; 103 104 Value htmlGetter(ExecState* exec, int token) const; 105 void htmlSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 106 Value headGetter(ExecState* exec, int token) const; 107 void headSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 108 Value linkGetter(ExecState* exec, int token) const; 109 void linkSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 110 Value titleGetter(ExecState* exec, int token) const; 111 void titleSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 112 Value metaGetter(ExecState* exec, int token) const; 113 void metaSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 114 Value baseGetter(ExecState* exec, int token) const; 115 void baseSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 116 Value isIndexGetter(ExecState* exec, int token) const; 117 void isIndexSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 118 Value styleGetter(ExecState* exec, int token) const; 119 void styleSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 120 Value bodyGetter(ExecState* exec, int token) const; 121 void bodySetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 122 Value formGetter(ExecState* exec, int token) const; 123 void formSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 124 Value selectGetter(ExecState* exec, int token) const; 125 void selectSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 126 Value optGroupGetter(ExecState* exec, int token) const; 127 void optGroupSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 128 Value optionGetter(ExecState* exec, int token) const; 129 void optionSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 130 Value inputGetter(ExecState* exec, int token) const; 131 void inputSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 132 Value textAreaGetter(ExecState* exec, int token) const; 133 void textAreaSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 134 Value buttonGetter(ExecState* exec, int token) const; 135 void buttonSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 136 Value labelGetter(ExecState* exec, int token) const; 137 void labelSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 138 Value fieldSetGetter(ExecState* exec, int token) const; 139 void fieldSetSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 140 Value legendGetter(ExecState* exec, int token) const; 141 void legendSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 142 Value uListGetter(ExecState* exec, int token) const; 143 void uListSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 144 Value oListGetter(ExecState* exec, int token) const; 145 void oListSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 146 Value dListGetter(ExecState* exec, int token) const; 147 void dListSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 148 Value dirGetter(ExecState* exec, int token) const; 149 void dirSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 150 Value menuGetter(ExecState* exec, int token) const; 151 void menuSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 152 Value liGetter(ExecState* exec, int token) const; 153 void liSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 154 Value divGetter(ExecState* exec, int token) const; 155 void divSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 156 Value paragraphGetter(ExecState* exec, int token) const; 157 void paragraphSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 158 Value headingGetter(ExecState* exec, int token) const; 159 void headingSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 160 Value blockQuoteGetter(ExecState* exec, int token) const; 161 void blockQuoteSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 162 Value quoteGetter(ExecState* exec, int token) const; 163 void quoteSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 164 Value preGetter(ExecState* exec, int token) const; 165 void preSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 166 Value brGetter(ExecState* exec, int token) const; 167 void brSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 168 Value baseFontGetter(ExecState* exec, int token) const; 169 void baseFontSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 170 Value fontGetter(ExecState* exec, int token) const; 171 void fontSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 172 Value hrGetter(ExecState* exec, int token) const; 173 void hrSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 174 Value modGetter(ExecState* exec, int token) const; 175 void modSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 176 Value anchorGetter(ExecState* exec, int token) const; 177 void anchorSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 178 Value imageGetter(ExecState* exec, int token) const; 179 void imageSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 180 Value objectGetter(ExecState* exec, int token) const; 181 void objectSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 182 Value paramGetter(ExecState* exec, int token) const; 183 void paramSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 184 Value appletGetter(ExecState* exec, int token) const; 185 void appletSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 186 Value mapGetter(ExecState* exec, int token) const; 187 void mapSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 188 Value areaGetter(ExecState* exec, int token) const; 189 void areaSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 190 Value scriptGetter(ExecState* exec, int token) const; 191 void scriptSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 192 Value tableGetter(ExecState* exec, int token) const; 193 void tableSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 194 Value tableCaptionGetter(ExecState* exec, int token) const; 195 void tableCaptionSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 196 Value tableColGetter(ExecState* exec, int token) const; 197 void tableColSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 198 Value tableSectionGetter(ExecState* exec, int token) const; 199 void tableSectionSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 200 Value tableRowGetter(ExecState* exec, int token) const; 201 void tableRowSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 202 Value tableCellGetter(ExecState* exec, int token) const; 203 void tableCellSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 204 Value frameSetGetter(ExecState* exec, int token) const; 205 void frameSetSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 206 Value frameGetter(ExecState* exec, int token) const; 207 void frameSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 208 Value iFrameGetter(ExecState* exec, int token) const; 209 void iFrameSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 210 Value marqueeGetter(ExecState* exec, int token) const; 211 void marqueeSetter(ExecState *exec, int token, const Value& value, const DOM::DOMString& str); 87 212 88 213 enum { HtmlVersion, HeadProfile, LinkHref, LinkRel, LinkMedia, -
trunk/WebCore/khtml/ecma/kjs_window.cpp
r9582 r9639 69 69 #include "css/css_ruleimpl.h" 70 70 #include "css/css_stylesheetimpl.h" 71 #include "misc/htmltags.h"72 71 73 72 // Must include <cmath> instead of <math.h> because of a bug in the -
trunk/WebCore/khtml/editing/SelectionController.cpp
r9476 r9639 34 34 #include "khtml_part.h" 35 35 #include "khtmlview.h" 36 #include "misc/htmltags.h"37 36 #include "rendering/render_object.h" 38 37 #include "rendering/render_style.h" … … 939 938 if (r->node()->isElementNode()) { 940 939 ElementImpl *element = static_cast<ElementImpl *>(r->node()); 941 fprintf(stderr, "%s%s\n", selected ? "==> " : " ", element-> tagName().string().latin1());940 fprintf(stderr, "%s%s\n", selected ? "==> " : " ", element->localName().string().latin1()); 942 941 } 943 942 else if (r->isText()) { -
trunk/WebCore/khtml/editing/apply_style_command.cpp
r9595 r9639 34 34 #include "dom/dom_string.h" 35 35 #include "html/html_elementimpl.h" 36 #include " misc/htmltags.h"36 #include "htmlnames.h" 37 37 #include "misc/htmlattrs.h" 38 38 #include "rendering/render_object.h" … … 66 66 using DOM::RangeImpl; 67 67 using DOM::TextImpl; 68 using DOM::HTMLNames; 68 69 69 70 namespace khtml { … … 250 251 251 252 const HTMLElementImpl *elem = static_cast<const HTMLElementImpl *>(node); 252 return elem-> id() == ID_SPAN&& elem->getAttribute(ATTR_CLASS) == styleSpanClassString();253 return elem->hasLocalName(HTMLNames::span()) && elem->getAttribute(ATTR_CLASS) == styleSpanClassString(); 253 254 } 254 255 255 256 static bool isEmptyStyleSpan(const NodeImpl *node) 256 257 { 257 if (!node || !node->isHTMLElement() || node->id() != ID_SPAN)258 if (!node || !node->isHTMLElement() || !node->hasTagName(HTMLNames::span())) 258 259 return false; 259 260 … … 265 266 static bool isEmptyFontTag(const NodeImpl *node) 266 267 { 267 if (!node || node->id() != ID_FONT)268 if (!node || !node->hasTagName(HTMLNames::font())) 268 269 return false; 269 270 … … 276 277 { 277 278 int exceptionCode = 0; 278 ElementImpl *fontNode = document->create HTMLElement("font", exceptionCode);279 ElementImpl *fontNode = document->createElementNS(HTMLNames::xhtmlNamespaceURI(), "font", exceptionCode); 279 280 ASSERT(exceptionCode == 0); 280 281 fontNode->setAttribute(ATTR_CLASS, styleSpanClassString()); … … 285 286 { 286 287 int exceptionCode = 0; 287 ElementImpl *styleElement = document->create HTMLElement("SPAN", exceptionCode);288 ElementImpl *styleElement = document->createElementNS(HTMLNames::xhtmlNamespaceURI(), "span", exceptionCode); 288 289 ASSERT(exceptionCode == 0); 289 290 styleElement->setAttribute(ATTR_CLASS, styleSpanClassString()); … … 587 588 if (node == end.node() || 588 589 runStart->parentNode() != next->parentNode() || 589 (next->is HTMLElement() && next->id() != ID_BR) ||590 (next->isElementNode() && !next->hasTagName(HTMLNames::br())) || 590 591 (next->renderer() && !next->renderer()->isInline())) 591 592 break; … … 612 613 switch ((*it).id()) { 613 614 case CSS_PROP_FONT_WEIGHT: 614 if (elem-> id() == ID_B)615 if (elem->hasLocalName(HTMLNames::b())) 615 616 return true; 616 617 break; 617 618 case CSS_PROP_FONT_STYLE: 618 if (elem-> id() == ID_I)619 if (elem->hasLocalName(HTMLNames::i())) 619 620 return true; 620 621 } … … 639 640 ASSERT(elem); 640 641 641 if ( elem->id() != ID_FONT)642 if (!elem->hasLocalName(HTMLNames::font())) 642 643 return; 643 644 … … 1048 1049 ElementImpl *secondElement = static_cast<ElementImpl *>(second); 1049 1050 1050 if ( firstElement->id() != secondElement->id())1051 if (!firstElement->tagName().matches(secondElement->tagName())) 1051 1052 return false; 1052 1053 … … 1130 1131 } 1131 1132 1132 if (!endNode->isElementNode() || endNode-> id() == ID_BR)1133 if (!endNode->isElementNode() || endNode->hasTagName(HTMLNames::br())) 1133 1134 return false; 1134 1135 … … 1275 1276 1276 1277 if (styleChange.applyBold()) { 1277 ElementImpl *boldElement = document()->create HTMLElement("B", exceptionCode);1278 ElementImpl *boldElement = document()->createElementNS(HTMLNames::xhtmlNamespaceURI(), "b", exceptionCode); 1278 1279 ASSERT(exceptionCode == 0); 1279 1280 insertNodeBefore(boldElement, startNode); … … 1282 1283 1283 1284 if (styleChange.applyItalic()) { 1284 ElementImpl *italicElement = document()->create HTMLElement("I", exceptionCode);1285 ElementImpl *italicElement = document()->createElementNS(HTMLNames::xhtmlNamespaceURI(), "i", exceptionCode); 1285 1286 ASSERT(exceptionCode == 0); 1286 1287 insertNodeBefore(italicElement, startNode); -
trunk/WebCore/khtml/editing/break_blockquote_command.cpp
r9196 r9639 29 29 #include "visible_position.h" 30 30 31 #include " misc/htmltags.h"31 #include "htmlnames.h" 32 32 #include "xml/dom_elementimpl.h" 33 33 #include "xml/dom_textimpl.h" … … 44 44 using DOM::Position; 45 45 using DOM::TextImpl; 46 using DOM::HTMLNames; 46 47 47 48 namespace khtml { … … 147 148 if (startNode != topBlockquote) { 148 149 NodeImpl *n = startNode; 149 startIsBR = n-> id() == ID_BR;150 startIsBR = n->hasTagName(HTMLNames::br()); 150 151 if (startIsBR) 151 152 n = n->nextSibling(); -
trunk/WebCore/khtml/editing/composite_edit_command.cpp
r9196 r9639 48 48 49 49 #include "misc/htmlattrs.h" 50 #include " misc/htmltags.h"50 #include "htmlnames.h" 51 51 #include "rendering/render_text.h" 52 52 #include "xml/dom2_rangeimpl.h" … … 68 68 using DOM::RangeImpl; 69 69 using DOM::TextImpl; 70 using DOM::HTMLNames; 70 71 71 72 namespace khtml { … … 128 129 void CompositeEditCommand::insertNodeBefore(NodeImpl *insertChild, NodeImpl *refChild) 129 130 { 130 ASSERT( refChild->id() != ID_BODY);131 ASSERT(!refChild->hasTagName(HTMLNames::body())); 131 132 EditCommandPtr cmd(new InsertNodeBeforeCommand(document(), insertChild, refChild)); 132 133 applyCommandToComposite(cmd); … … 135 136 void CompositeEditCommand::insertNodeAfter(NodeImpl *insertChild, NodeImpl *refChild) 136 137 { 137 ASSERT( refChild->id() != ID_BODY);138 ASSERT(!refChild->hasTagName(HTMLNames::body())); 138 139 if (refChild->parentNode()->lastChild() == refChild) { 139 140 appendNode(insertChild, refChild->parentNode()); … … 546 547 NodeImpl *startBlock = paragraphStart.node()->enclosingBlockFlowElement(); 547 548 NodeImpl *newBlock = 0; 548 if (startBlock-> id() == ID_BODY|| (isMailBlockquote(startBlock) && paragraphStart.node() != startBlock))549 if (startBlock->hasTagName(HTMLNames::body()) || (isMailBlockquote(startBlock) && paragraphStart.node() != startBlock)) 549 550 newBlock = createDefaultParagraphElement(document()); 550 551 else … … 556 557 NodeImpl *endNode = paragraphEnd.node(); 557 558 558 if (paragraphStart.node()-> id() == ID_BODY) {559 if (paragraphStart.node()->hasTagName(HTMLNames::body())) { 559 560 insertNodeAt(newBlock, paragraphStart.node(), 0); 560 561 } 561 else if (paragraphStart.node()-> id() == ID_BR) {562 else if (paragraphStart.node()->hasTagName(HTMLNames::br())) { 562 563 insertNodeAfter(newBlock, paragraphStart.node()); 563 564 } … … 579 580 { 580 581 int exceptionCode = 0; 581 ElementImpl *breakNode = document->create HTMLElement("br", exceptionCode);582 ElementImpl *breakNode = document->createElementNS(HTMLNames::xhtmlNamespaceURI(), "br", exceptionCode); 582 583 ASSERT(exceptionCode == 0); 583 584 breakNode->setAttribute(ATTR_CLASS, blockPlaceholderClassString()); -
trunk/WebCore/khtml/editing/delete_selection_command.cpp
r9595 r9639 29 29 #include "htmlediting.h" 30 30 #include "khtml_part.h" 31 #include " misc/htmltags.h"31 #include "htmlnames.h" 32 32 #include "rendering/render_line.h" 33 33 #include "rendering/render_object.h" … … 54 54 using DOM::RangeImpl; 55 55 using DOM::TextImpl; 56 using DOM::HTMLNames; 56 57 57 58 namespace khtml { … … 62 63 // but here we also have to peek at the type of DOM node? 63 64 RenderObject *r = node->renderer(); 64 NodeImpl::Id nodeID = node->id();65 65 return (r && r->isListItem()) 66 || (nodeID == ID_OL || nodeID == ID_UL || nodeID == ID_DD || nodeID == ID_DT || nodeID == ID_DIR || nodeID == ID_MENU); 66 || node->hasTagName(HTMLNames::ol()) 67 || node->hasTagName(HTMLNames::ul()) 68 || node->hasTagName(HTMLNames::dd()) 69 || node->hasTagName(HTMLNames::dt()) 70 || node->hasTagName(HTMLNames::dir()) 71 || node->hasTagName(HTMLNames::menu()); 67 72 } 68 73 … … 278 283 { 279 284 // Check for special-case where the selection contains only a BR on a line by itself after another BR. 280 bool upstreamStartIsBR = m_startNode-> id() == ID_BR;281 bool downstreamStartIsBR = m_downstreamStart.node()-> id() == ID_BR;285 bool upstreamStartIsBR = m_startNode->hasTagName(HTMLNames::br()); 286 bool downstreamStartIsBR = m_downstreamStart.node()->hasTagName(HTMLNames::br()); 282 287 bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && m_downstreamStart.node() == m_upstreamEnd.node(); 283 288 if (isBROnLineByItself) { … … 327 332 // start block, otherwise delete the start block. 328 333 // A similar case is provided to cover selections starting in BR elements. 329 if (startOffset == 1 && m_startNode && m_startNode-> id() == ID_BR) {334 if (startOffset == 1 && m_startNode && m_startNode->hasTagName(HTMLNames::br())) { 330 335 setStartNode(m_startNode->traverseNextNode()); 331 336 startOffset = 0; 332 337 } 333 if (m_startBlock != m_endBlock && startOffset == 0 && m_startNode && m_startNode-> id() == ID_BR&& endAtEndOfBlock) {338 if (m_startBlock != m_endBlock && startOffset == 0 && m_startNode && m_startNode->hasTagName(HTMLNames::br()) && endAtEndOfBlock) { 334 339 // Don't delete the BR element 335 340 setStartNode(m_startNode->traverseNextNode()); … … 553 558 node = node->nextSibling(); 554 559 removeNode(moveNode); 555 if (moveNode-> id() == ID_BR&& !moveNode->renderer()) {560 if (moveNode->hasTagName(HTMLNames::br()) && !moveNode->renderer()) { 556 561 // Just remove this node, and don't put it back. 557 562 // If the BR was not rendered (since it was at the end of a block, for instance), … … 564 569 insertNodeAfter(moveNode, refNode); 565 570 refNode = moveNode; 566 if (moveNode-> id() == ID_BR)571 if (moveNode->hasTagName(HTMLNames::br())) 567 572 break; 568 573 } -
trunk/WebCore/khtml/editing/htmlediting.cpp
r9595 r9639 43 43 #include "html_interchange.h" 44 44 #include "htmlattrs.h" 45 #include "html tags.h"45 #include "htmlnames.h" 46 46 #include "khtml_part.h" 47 47 #include "khtml_part.h" … … 82 82 using DOM::TextImpl; 83 83 using DOM::TreeWalkerImpl; 84 using DOM::HTMLNames; 84 85 85 86 #if APPLE_CHANGES … … 132 133 return false; 133 134 134 if (n->i d() == ID_A && n->isLink())135 return true; 136 137 if (n-> id() == ID_UL || n->id() == ID_OL || n->id() == ID_DL)135 if (n->isLink()) 136 return true; 137 138 if (n->hasTagName(HTMLNames::ul()) || n->hasTagName(HTMLNames::ol()) || n->hasTagName(HTMLNames::dl())) 138 139 return true; 139 140 … … 268 269 // static const DOMString defaultParagraphStyle("margin-top: 0; margin-bottom: 0"); 269 270 int exceptionCode = 0; 270 ElementImpl *element = document->create HTMLElement("div", exceptionCode);271 ElementImpl *element = document->createElementNS(HTMLNames::xhtmlNamespaceURI(), "div", exceptionCode); 271 272 ASSERT(exceptionCode == 0); 272 273 return element; … … 276 277 { 277 278 int exceptionCode = 0; 278 ElementImpl *breakNode = document->create HTMLElement("br", exceptionCode);279 ElementImpl *breakNode = document->createElementNS(HTMLNames::xhtmlNamespaceURI(), "br", exceptionCode); 279 280 ASSERT(exceptionCode == 0); 280 281 return breakNode; … … 304 305 bool isMailBlockquote(const NodeImpl *node) 305 306 { 306 if (!node || !node->renderer() || !node->isElementNode() && node->id() != ID_BLOCKQUOTE)307 if (!node || !node->renderer() || !node->isElementNode() && !node->hasTagName(HTMLNames::blockquote())) 307 308 return false; 308 309 -
trunk/WebCore/khtml/editing/insert_line_break_command.cpp
r9196 r9639 30 30 #include "visible_units.h" 31 31 32 #include " misc/htmltags.h"32 #include "htmlnames.h" 33 33 #include "xml/dom_docimpl.h" 34 34 #include "xml/dom_elementimpl.h" … … 51 51 using DOM::TextImpl; 52 52 using DOM::CSSMutableStyleDeclarationImpl; 53 using DOM::HTMLNames; 53 54 54 55 namespace khtml { … … 112 113 // significant side effects (and no real worries either since you can't arrow past 113 114 // this extra one. 114 if (pos.node()-> id() == ID_BR&& pos.offset() == 0) {115 if (pos.node()->hasTagName(HTMLNames::br()) && pos.offset() == 0) { 115 116 // Already placed in a trailing BR. Insert "real" BR before it and leave the selection alone. 116 117 insertNodeBefore(nodeToInsert, pos.node()); … … 118 119 else { 119 120 NodeImpl *next = pos.node()->traverseNextNode(); 120 bool hasTrailingBR = next && next-> id() == ID_BR&& pos.node()->enclosingBlockFlowElement() == next->enclosingBlockFlowElement();121 bool hasTrailingBR = next && next->hasTagName(HTMLNames::br()) && pos.node()->enclosingBlockFlowElement() == next->enclosingBlockFlowElement(); 121 122 insertNodeAfterPosition(nodeToInsert, pos); 122 123 if (hasTrailingBR) { -
trunk/WebCore/khtml/editing/insert_paragraph_separator_command.cpp
r9196 r9639 32 32 #include "css/css_computedstyle.h" 33 33 #include "css/css_valueimpl.h" 34 #include " misc/htmltags.h"34 #include "htmlnames.h" 35 35 #include "xml/dom_docimpl.h" 36 36 #include "xml/dom_elementimpl.h" … … 51 51 using DOM::Position; 52 52 using DOM::TextImpl; 53 using DOM::HTMLNames; 53 54 54 55 namespace khtml { … … 214 215 if (!document()->inStrictMode()) { 215 216 Position upstreamPos = pos.upstream(); 216 if (upstreamPos.node()-> id() == ID_BR)217 if (upstreamPos.node()->hasTagName(HTMLNames::br())) 217 218 insertNodeAfter(createBreakElement(document()), upstreamPos.node()); 218 219 } -
trunk/WebCore/khtml/editing/markup.cpp
r9595 r9639 37 37 #include "rendering/render_text.h" 38 38 #include "misc/htmlattrs.h" 39 #include "misc/htmltags.h" 40 #include "html/dtd.h" 39 #include "htmlnames.h" 41 40 42 41 using DOM::AttributeImpl; … … 48 47 using DOM::DOMString; 49 48 using DOM::ElementImpl; 50 using DOM::FORBIDDEN; 51 using DOM::endTagRequirement; 49 using DOM::TagStatusForbidden; 52 50 using DOM::HTMLElementImpl; 51 using DOM::HTMLNames; 53 52 using DOM::NamedAttrMapImpl; 54 53 using DOM::Node; … … 178 177 case Node::TEXT_NODE: { 179 178 if (node->parentNode()) { 180 switch (node->parentNode()->id()) { 181 case ID_PRE: 182 case ID_SCRIPT: 183 case ID_STYLE: 184 case ID_TEXTAREA: 185 return stringValueForRange(node, range); 186 } 179 if (node->parentNode()->hasTagName(HTMLNames::pre()) || 180 node->parentNode()->hasTagName(HTMLNames::script()) || 181 node->parentNode()->hasTagName(HTMLNames::style()) || 182 node->parentNode()->hasTagName(HTMLNames::textarea())) 183 return stringValueForRange(node, range); 187 184 } 188 185 QString markup = annotate ? escapeHTML(renderedText(node, range)) : escapeHTML(stringValueForRange(node, range)); … … 249 246 static QString endMarkup(const NodeImpl *node) 250 247 { 251 if ((!node->isHTMLElement() || endTagRequirement(node->id()) != FORBIDDEN) && node->nodeType() != Node::TEXT_NODE && node->nodeType() != Node::DOCUMENT_NODE) { 248 bool hasEndTag = node->isElementNode(); 249 if (node->isHTMLElement()) { 250 const HTMLElementImpl* htmlElt = static_cast<const HTMLElementImpl*>(node); 251 hasEndTag = (htmlElt->endTagRequirement() != TagStatusForbidden); 252 } 253 if (hasEndTag) 252 254 return "</" + node->nodeName().string() + ">"; 253 }254 255 return ""; 255 256 } … … 266 267 } 267 268 me += startMarkup(current, 0, DoNotAnnotateForInterchange, 0); 268 } 269 if (!current->isHTMLElement() || endTagRequirement(current->id()) != FORBIDDEN) { 269 } 270 271 bool container = true; 272 if (current->isHTMLElement()) { 273 const HTMLElementImpl* h = static_cast<const HTMLElementImpl*>(current); 274 container = h->endTagRequirement() != TagStatusForbidden; 275 } 276 if (container) { 270 277 // print children 271 278 if (NodeImpl *n = current->firstChild()) { … … 415 422 bool breakAtEnd = false; 416 423 if (commonAncestorBlock == ancestor) { 417 NodeImpl::Id id = ancestor->id();418 424 // Include ancestors that are required to retain the appearance of the copied markup. 419 if (id == ID_PRE || id == ID_TABLE || id == ID_OL || id == ID_UL) { 425 if (ancestor->hasTagName(HTMLNames::pre()) || ancestor->hasTagName(HTMLNames::table()) || 426 ancestor->hasTagName(HTMLNames::ol()) || ancestor->hasTagName(HTMLNames::ul())) { 420 427 breakAtEnd = true; 421 428 } else { … … 540 547 if (s.isEmpty() && list.isEmpty()) { 541 548 // For last line, use the "magic BR" rather than a P. 542 element = document->create HTMLElement("br", exceptionCode);549 element = document->createElementNS(HTMLNames::xhtmlNamespaceURI(), "br", exceptionCode); 543 550 ASSERT(exceptionCode == 0); 544 551 element->ref(); -
trunk/WebCore/khtml/editing/replace_selection_command.cpp
r9595 r9639 28 28 #include "visible_position.h" 29 29 #include "misc/htmlattrs.h" 30 #include " misc/htmltags.h"30 #include "htmlnames.h" 31 31 #include "xml/dom_docimpl.h" 32 32 #include "html_interchange.h" … … 59 59 using DOM::CSSMutableStyleDeclarationImpl; 60 60 using DOM::Position; 61 using DOM::HTMLNames; 61 62 62 63 namespace khtml { … … 168 169 return false; 169 170 170 switch (node->id()) { 171 case ID_BLOCKQUOTE: 172 case ID_DD: 173 case ID_DIV: 174 case ID_DL: 175 case ID_DT: 176 case ID_H1: 177 case ID_H2: 178 case ID_H3: 179 case ID_H4: 180 case ID_H5: 181 case ID_H6: 182 case ID_HR: 183 case ID_LI: 184 case ID_OL: 185 case ID_P: 186 case ID_PRE: 187 case ID_TD: 188 case ID_TH: 189 case ID_UL: 190 return true; 191 } 192 193 return false; 171 // FIXME: This function seems really broken to me. It isn't even including all the block-level elements. 172 return (node->hasTagName(HTMLNames::blockquote()) || node->hasTagName(HTMLNames::dd()) || node->hasTagName(HTMLNames::div()) || 173 node->hasTagName(HTMLNames::dl()) || node->hasTagName(HTMLNames::dt()) || node->hasTagName(HTMLNames::h1()) || 174 node->hasTagName(HTMLNames::h2()) || node->hasTagName(HTMLNames::h3()) || node->hasTagName(HTMLNames::h4()) || 175 node->hasTagName(HTMLNames::h5()) || node->hasTagName(HTMLNames::h6()) || node->hasTagName(HTMLNames::hr()) || 176 node->hasTagName(HTMLNames::li()) || node->hasTagName(HTMLNames::ol()) || node->hasTagName(HTMLNames::p()) || 177 node->hasTagName(HTMLNames::pre()) || node->hasTagName(HTMLNames::td()) || node->hasTagName(HTMLNames::th()) || 178 node->hasTagName(HTMLNames::ul())); 194 179 } 195 180 … … 215 200 return false; 216 201 217 switch (node->id()) { 218 case ID_TABLE: 219 case ID_TBODY: 220 case ID_TD: 221 case ID_TFOOT: 222 case ID_THEAD: 223 case ID_TR: 224 return true; 225 } 226 return false; 202 return (node->hasTagName(HTMLNames::table()) || node->hasTagName(HTMLNames::tbody()) || node->hasTagName(HTMLNames::td()) || 203 node->hasTagName(HTMLNames::tfoot()) || node->hasTagName(HTMLNames::thead()) || node->hasTagName(HTMLNames::tr())); 227 204 } 228 205 … … 251 228 { 252 229 static DOMString interchangeNewlineClassString(AppleInterchangeNewline); 253 return node && node-> id() == ID_BR&& static_cast<const ElementImpl *>(node)->getAttribute(ATTR_CLASS) == interchangeNewlineClassString;230 return node && node->hasTagName(HTMLNames::br()) && static_cast<const ElementImpl *>(node)->getAttribute(ATTR_CLASS) == interchangeNewlineClassString; 254 231 } 255 232 … … 508 485 // This list of tags change the appearance of content 509 486 // in ways we can add back on later with CSS, if necessary. 510 if (node->id() == ID_B || 511 node->id() == ID_BIG || 512 node->id() == ID_CENTER || 513 node->id() == ID_FONT || 514 node->id() == ID_I || 515 node->id() == ID_S || 516 node->id() == ID_SMALL || 517 node->id() == ID_STRIKE || 518 node->id() == ID_SUB || 519 node->id() == ID_SUP || 520 node->id() == ID_TT || 521 node->id() == ID_U || 487 // FIXME: This list is incomplete 488 if (node->hasTagName(HTMLNames::b()) || 489 node->hasTagName(HTMLNames::big()) || 490 node->hasTagName(HTMLNames::center()) || 491 node->hasTagName(HTMLNames::font()) || 492 node->hasTagName(HTMLNames::i()) || 493 node->hasTagName(HTMLNames::s()) || 494 node->hasTagName(HTMLNames::small()) || 495 node->hasTagName(HTMLNames::strike()) || 496 node->hasTagName(HTMLNames::sub()) || 497 node->hasTagName(HTMLNames::sup()) || 498 node->hasTagName(HTMLNames::tt()) || 499 node->hasTagName(HTMLNames::u()) || 522 500 isStyleSpan(node)) { 523 501 removeNodePreservingChildren(node); … … 745 723 Position downstream = startPos.downstream(); 746 724 downstream = positionOutsideContainingSpecialElement(downstream); 747 if (downstream.node()-> id() == ID_BR&& downstream.offset() == 0 &&725 if (downstream.node()->hasTagName(HTMLNames::br()) && downstream.offset() == 0 && 748 726 m_fragment.hasInterchangeNewlineAtEnd() && 749 727 isStartOfLine(VisiblePosition(downstream, VP_DEFAULT_AFFINITY))) … … 907 885 } 908 886 else { 909 if (m_lastNodeInserted && m_lastNodeInserted-> id() == ID_BR&& !document()->inStrictMode()) {887 if (m_lastNodeInserted && m_lastNodeInserted->hasTagName(HTMLNames::br()) && !document()->inStrictMode()) { 910 888 document()->updateLayout(); 911 889 VisiblePosition pos(Position(m_lastNodeInserted, 1), DOWNSTREAM); 912 890 if (isEndOfBlock(pos)) { 913 891 NodeImpl *next = m_lastNodeInserted->traverseNextNode(); 914 bool hasTrailingBR = next && next-> id() == ID_BR&& m_lastNodeInserted->enclosingBlockFlowElement() == next->enclosingBlockFlowElement();892 bool hasTrailingBR = next && next->hasTagName(HTMLNames::br()) && m_lastNodeInserted->enclosingBlockFlowElement() == next->enclosingBlockFlowElement(); 915 893 if (!hasTrailingBR) { 916 894 // Insert an "extra" BR at the end of the block. … … 939 917 refNode = node; 940 918 // We want to move the first BR we see, so check for that here. 941 if (node-> id() == ID_BR)919 if (node->hasTagName(HTMLNames::br())) 942 920 break; 943 921 node = next; … … 1087 1065 // update m_lastNodeInserted 1088 1066 NodeImpl *old = m_lastNodeInserted; 1089 m_lastNodeInserted = node->lastDescend ent();1067 m_lastNodeInserted = node->lastDescendant(); 1090 1068 m_lastNodeInserted->ref(); 1091 1069 if (old) -
trunk/WebCore/khtml/editing/selection.cpp
r9476 r9639 34 34 #include "khtml_part.h" 35 35 #include "khtmlview.h" 36 #include "misc/htmltags.h"37 36 #include "rendering/render_object.h" 38 37 #include "rendering/render_style.h" … … 939 938 if (r->node()->isElementNode()) { 940 939 ElementImpl *element = static_cast<ElementImpl *>(r->node()); 941 fprintf(stderr, "%s%s\n", selected ? "==> " : " ", element-> tagName().string().latin1());940 fprintf(stderr, "%s%s\n", selected ? "==> " : " ", element->localName().string().latin1()); 942 941 } 943 942 else if (r->isText()) { -
trunk/WebCore/khtml/editing/visible_position.cpp
r9476 r9639 27 27 #include "visible_units.h" 28 28 29 #include " misc/htmltags.h"29 #include "htmlnames.h" 30 30 #include "rendering/render_line.h" 31 31 #include "rendering/render_object.h" … … 51 51 using DOM::RangeImpl; 52 52 using DOM::TextImpl; 53 using DOM::HTMLNames; 53 54 54 55 namespace khtml { … … 75 76 76 77 // For <br> 0, it's important not to move past the <br>. 77 if (pos.node() && pos.node()-> id() == ID_BR&& pos.offset() == 0)78 if (pos.node() && pos.node()->hasTagName(HTMLNames::br()) && pos.offset() == 0) 78 79 initUpstream(pos); 79 80 else … … 275 276 276 277 if (renderer->isBlockFlow() && (!renderer->firstChild() || !pos.node()->firstChild()) && 277 (renderer->height() || pos.node()-> id() == ID_BODY)) {278 (renderer->height() || pos.node()->hasTagName(HTMLNames::body()))) { 278 279 // return true for offset 0 into rendered blocks that are empty of rendered kids, but have a height 279 280 return pos.offset() == 0; … … 360 361 bool VisiblePosition::isAtomicNode(const NodeImpl *node) 361 362 { 362 return node && (!node->hasChildNodes() || (node-> id() == ID_OBJECT&& node->renderer() && node->renderer()->isReplaced()));363 return node && (!node->hasChildNodes() || (node->hasTagName(HTMLNames::object()) && node->renderer() && node->renderer()->isReplaced())); 363 364 } 364 365 -
trunk/WebCore/khtml/editing/visible_text.cpp
r9169 r9639 26 26 #include "visible_text.h" 27 27 28 #include " misc/htmltags.h"28 #include "htmlnames.h" 29 29 #include "rendering/render_text.h" 30 30 #include "xml/dom_nodeimpl.h" … … 38 38 using DOM::offsetInCharacters; 39 39 using DOM::RangeImpl; 40 using DOM::HTMLNames; 40 41 41 42 // FIXME: These classes should probably use the render tree and not the DOM tree, since elements could … … 337 338 bool TextIterator::handleNonTextNode() 338 339 { 339 switch (m_node->id()) { 340 case ID_BR: { 341 emitCharacter('\n', m_node->parentNode(), m_node, 0, 1); 342 break; 343 } 344 345 case ID_TD: 346 case ID_TH: 347 if (m_lastCharacter != '\n' && m_lastTextNode) { 348 emitCharacter('\t', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1); 349 } 350 break; 351 352 case ID_BLOCKQUOTE: 353 case ID_DD: 354 case ID_DIV: 355 case ID_DL: 356 case ID_DT: 357 case ID_H1: 358 case ID_H2: 359 case ID_H3: 360 case ID_H4: 361 case ID_H5: 362 case ID_H6: 363 case ID_HR: 364 case ID_LI: 365 case ID_OL: 366 case ID_P: 367 case ID_PRE: 368 case ID_TR: 369 case ID_UL: 370 if (m_lastCharacter != '\n' && m_lastTextNode) { 371 emitCharacter('\n', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1); 372 } 373 break; 340 if (m_node->hasTagName(HTMLNames::br())) { 341 emitCharacter('\n', m_node->parentNode(), m_node, 0, 1); 342 } else if (m_node->hasTagName(HTMLNames::td()) || m_node->hasTagName(HTMLNames::th())) { 343 if (m_lastCharacter != '\n' && m_lastTextNode) { 344 emitCharacter('\t', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1); 345 } 346 } else if (m_node->hasTagName(HTMLNames::blockquote()) || m_node->hasTagName(HTMLNames::dd()) || 347 m_node->hasTagName(HTMLNames::div()) || 348 m_node->hasTagName(HTMLNames::dl()) || m_node->hasTagName(HTMLNames::dt()) || 349 m_node->hasTagName(HTMLNames::h1()) || m_node->hasTagName(HTMLNames::h2()) || 350 m_node->hasTagName(HTMLNames::h3()) || m_node->hasTagName(HTMLNames::h4()) || 351 m_node->hasTagName(HTMLNames::h5()) || m_node->hasTagName(HTMLNames::h6()) || 352 m_node->hasTagName(HTMLNames::hr()) || m_node->hasTagName(HTMLNames::li()) || 353 m_node->hasTagName(HTMLNames::ol()) || m_node->hasTagName(HTMLNames::p()) || 354 m_node->hasTagName(HTMLNames::pre()) || m_node->hasTagName(HTMLNames::tr()) || 355 m_node->hasTagName(HTMLNames::ul())) { 356 if (m_lastCharacter != '\n' && m_lastTextNode) { 357 emitCharacter('\n', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1); 358 } 374 359 } 375 360 … … 382 367 bool addNewline = false; 383 368 384 switch (m_node->id()) { 385 case ID_BLOCKQUOTE: 386 case ID_DD: 387 case ID_DIV: 388 case ID_DL: 389 case ID_DT: 390 case ID_HR: 391 case ID_LI: 392 case ID_OL: 393 case ID_PRE: 394 case ID_TR: 395 case ID_UL: 396 endLine = true; 397 break; 398 399 case ID_H1: 400 case ID_H2: 401 case ID_H3: 402 case ID_H4: 403 case ID_H5: 404 case ID_H6: 405 case ID_P: { 406 endLine = true; 407 408 // In certain cases, emit a new newline character for this node 409 // regardless of whether we emit another one. 410 // FIXME: Some day we could do this for other tags. 411 // However, doing it just for the tags above makes it more likely 412 // we'll end up getting the right result without margin collapsing. 413 // For example: <div><p>text</p></div> will work right even if both 414 // the <div> and the <p> have bottom margins. 415 RenderObject *renderer = m_node->renderer(); 416 if (renderer) { 417 RenderStyle *style = renderer->style(); 418 if (style) { 419 int bottomMargin = renderer->collapsedMarginBottom(); 420 int fontSize = style->htmlFont().getFontDef().computedPixelSize(); 421 if (bottomMargin * 2 >= fontSize) { 422 addNewline = true; 423 } 369 if (m_node->hasTagName(HTMLNames::blockquote()) || m_node->hasTagName(HTMLNames::dd()) || 370 m_node->hasTagName(HTMLNames::div()) || 371 m_node->hasTagName(HTMLNames::dl()) || m_node->hasTagName(HTMLNames::dt()) || 372 m_node->hasTagName(HTMLNames::hr()) || m_node->hasTagName(HTMLNames::li()) || 373 m_node->hasTagName(HTMLNames::ol()) || 374 m_node->hasTagName(HTMLNames::pre()) || m_node->hasTagName(HTMLNames::tr()) || 375 m_node->hasTagName(HTMLNames::ul())) 376 endLine = true; 377 else if (m_node->hasTagName(HTMLNames::h1()) || m_node->hasTagName(HTMLNames::h2()) || 378 m_node->hasTagName(HTMLNames::h3()) || m_node->hasTagName(HTMLNames::h4()) || 379 m_node->hasTagName(HTMLNames::h5()) || m_node->hasTagName(HTMLNames::h6()) || 380 m_node->hasTagName(HTMLNames::p())) { 381 endLine = true; 382 383 // In certain cases, emit a new newline character for this node 384 // regardless of whether we emit another one. 385 // FIXME: Some day we could do this for other tags. 386 // However, doing it just for the tags above makes it more likely 387 // we'll end up getting the right result without margin collapsing. 388 // For example: <div><p>text</p></div> will work right even if both 389 // the <div> and the <p> have bottom margins. 390 RenderObject *renderer = m_node->renderer(); 391 if (renderer) { 392 RenderStyle *style = renderer->style(); 393 if (style) { 394 int bottomMargin = renderer->collapsedMarginBottom(); 395 int fontSize = style->htmlFont().getFontDef().computedPixelSize(); 396 if (bottomMargin * 2 >= fontSize) { 397 addNewline = true; 424 398 } 425 399 } 426 break;427 400 } 428 401 } … … 661 634 bool SimplifiedBackwardsTextIterator::handleNonTextNode() 662 635 { 663 switch (m_node->id()) { 664 case ID_BR: 665 emitNewlineForBROrText(); 666 break; 667 case ID_TD: 668 case ID_TH: 669 case ID_BLOCKQUOTE: 670 case ID_DD: 671 case ID_DIV: 672 case ID_DL: 673 case ID_DT: 674 case ID_H1: 675 case ID_H2: 676 case ID_H3: 677 case ID_H4: 678 case ID_H5: 679 case ID_H6: 680 case ID_HR: 681 case ID_P: 682 case ID_PRE: 683 case ID_TR: 684 case ID_OL: 685 case ID_UL: 686 case ID_LI: 687 // Emit a space to "break up" content. Any word break 688 // character will do. 689 emitCharacter(' ', m_node, 0, 0); 690 break; 636 if (m_node->hasTagName(HTMLNames::br())) 637 emitNewlineForBROrText(); 638 else if (m_node->hasTagName(HTMLNames::td ()) || m_node->hasTagName(HTMLNames::th()) || 639 m_node->hasTagName(HTMLNames::blockquote()) || m_node->hasTagName(HTMLNames::dd()) || 640 m_node->hasTagName(HTMLNames::div()) || 641 m_node->hasTagName(HTMLNames::dl()) || m_node->hasTagName(HTMLNames::dt()) || 642 m_node->hasTagName(HTMLNames::h1()) || m_node->hasTagName(HTMLNames::h2()) || 643 m_node->hasTagName(HTMLNames::h3()) || m_node->hasTagName(HTMLNames::h4()) || 644 m_node->hasTagName(HTMLNames::h5()) || m_node->hasTagName(HTMLNames::h6()) || 645 m_node->hasTagName(HTMLNames::hr()) || m_node->hasTagName(HTMLNames::li()) || 646 m_node->hasTagName(HTMLNames::ol()) || m_node->hasTagName(HTMLNames::p()) || 647 m_node->hasTagName(HTMLNames::pre()) || m_node->hasTagName(HTMLNames::tr()) || 648 m_node->hasTagName(HTMLNames::ul())) { 649 // Emit a space to "break up" content. Any word break 650 // character will do. 651 emitCharacter(' ', m_node, 0, 0); 691 652 } 692 653 -
trunk/WebCore/khtml/editing/visible_units.cpp
r9217 r9639 28 28 #include <qstring.h> 29 29 30 #include "html tags.h"30 #include "htmlnames.h" 31 31 #include "misc/helper.h" 32 32 #include "rendering/render_text.h" … … 42 42 using DOM::Position; 43 43 using DOM::RangeImpl; 44 using DOM::HTMLNames; 44 45 45 46 namespace khtml { … … 333 334 334 335 long endOffset = 1; 335 if (endNode-> id() == ID_BR) {336 if (endNode->hasTagName(HTMLNames::br())) { 336 337 endOffset = 0; 337 338 } else if (endBox->isInlineTextBox()) { -
trunk/WebCore/khtml/html/html_baseimpl.cpp
r9165 r9639 49 49 50 50 HTMLBodyElementImpl::HTMLBodyElementImpl(DocumentPtr *doc) 51 : HTMLElementImpl( doc), m_linkDecl(0)51 : HTMLElementImpl(HTMLNames::body(), doc), m_linkDecl(0) 52 52 { 53 53 } … … 60 60 m_linkDecl->deref(); 61 61 } 62 }63 64 NodeImpl::Id HTMLBodyElementImpl::id() const65 {66 return ID_BODY;67 62 } 68 63 … … 290 285 291 286 HTMLFrameElementImpl::HTMLFrameElementImpl(DocumentPtr *doc) 292 : HTMLElementImpl(doc) 287 : HTMLElementImpl(HTMLNames::frame(), doc) 288 { 289 init(); 290 } 291 292 HTMLFrameElementImpl::HTMLFrameElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 293 : HTMLElementImpl(tagName, doc) 294 { 295 init(); 296 } 297 298 void HTMLFrameElementImpl::init() 293 299 { 294 300 m_frameBorder = true; … … 302 308 HTMLFrameElementImpl::~HTMLFrameElementImpl() 303 309 { 304 }305 306 NodeImpl::Id HTMLFrameElementImpl::id() const307 {308 return ID_FRAME;309 310 } 310 311 … … 483 484 // inherit default settings from parent frameset 484 485 for (NodeImpl *node = parentNode(); node; node = node->parentNode()) 485 if (node-> id() == ID_FRAMESET) {486 if (node->hasTagName(HTMLNames::frameset())) { 486 487 HTMLFrameSetElementImpl* frameset = static_cast<HTMLFrameSetElementImpl*>(node); 487 488 if (!m_frameBorderSet) … … 662 663 663 664 HTMLFrameSetElementImpl::HTMLFrameSetElementImpl(DocumentPtr *doc) 664 : HTMLElementImpl( doc)665 : HTMLElementImpl(HTMLNames::frameset(), doc) 665 666 { 666 667 // default value for rows and cols... … … 686 687 } 687 688 688 NodeImpl::Id HTMLFrameSetElementImpl::id() const 689 { 690 return ID_FRAMESET; 689 bool HTMLFrameSetElementImpl::checkDTD(const NodeImpl* newChild) 690 { 691 // FIXME: Old code had adjacent double returns and seemed to want to do something with NOFRAMES (but didn't). 692 // What is the correct behavior? 693 return newChild->hasTagName(HTMLNames::frameset()) || newChild->hasTagName(HTMLNames::frame()); 691 694 } 692 695 … … 753 756 while(node) 754 757 { 755 if(node->id() == ID_FRAMESET) 756 { 758 if (node->hasTagName(HTMLNames::frameset())) { 757 759 HTMLFrameSetElementImpl* frameset = static_cast<HTMLFrameSetElementImpl*>(node); 758 760 if(!frameBorderSet) frameborder = frameset->frameBorder(); … … 818 820 819 821 HTMLHeadElementImpl::HTMLHeadElementImpl(DocumentPtr *doc) 820 : HTMLElementImpl( doc)822 : HTMLElementImpl(HTMLNames::head(), doc) 821 823 { 822 824 } … … 826 828 } 827 829 828 NodeImpl::Id HTMLHeadElementImpl::id() const829 {830 return ID_HEAD;831 }832 833 830 DOMString HTMLHeadElementImpl::profile() const 834 831 { … … 841 838 } 842 839 840 bool HTMLHeadElementImpl::checkDTD(const NodeImpl* newChild) 841 { 842 return newChild->hasTagName(HTMLNames::title()) || newChild->hasTagName(HTMLNames::isindex()) || 843 newChild->hasTagName(HTMLNames::base()) || newChild->hasTagName(HTMLNames::script()) || 844 newChild->hasTagName(HTMLNames::style()) || newChild->hasTagName(HTMLNames::meta()) || 845 newChild->hasTagName(HTMLNames::link()) || newChild->isTextNode(); 846 } 847 843 848 // ------------------------------------------------------------------------- 844 849 845 850 HTMLHtmlElementImpl::HTMLHtmlElementImpl(DocumentPtr *doc) 846 : HTMLElementImpl( doc)851 : HTMLElementImpl(HTMLNames::html(), doc) 847 852 { 848 853 } … … 852 857 } 853 858 854 NodeImpl::Id HTMLHtmlElementImpl::id() const855 {856 return ID_HTML;857 }858 859 859 DOMString HTMLHtmlElementImpl::version() const 860 860 { … … 867 867 } 868 868 869 bool HTMLHtmlElementImpl::checkDTD(const NodeImpl* newChild) 870 { 871 // FIXME: Why is <script> allowed here? 872 return newChild->hasTagName(HTMLNames::head()) || newChild->hasTagName(HTMLNames::body()) || 873 newChild->hasTagName(HTMLNames::frameset()) || newChild->hasTagName(HTMLNames::noframes()) || 874 newChild->hasTagName(HTMLNames::script()); 875 } 876 869 877 // ------------------------------------------------------------------------- 870 878 871 HTMLIFrameElementImpl::HTMLIFrameElementImpl(DocumentPtr *doc) : HTMLFrameElementImpl( doc)879 HTMLIFrameElementImpl::HTMLIFrameElementImpl(DocumentPtr *doc) : HTMLFrameElementImpl(HTMLNames::iframe(), doc) 872 880 { 873 881 m_frameBorder = false; … … 879 887 HTMLIFrameElementImpl::~HTMLIFrameElementImpl() 880 888 { 881 }882 883 NodeImpl::Id HTMLIFrameElementImpl::id() const884 {885 return ID_IFRAME;886 889 } 887 890 -
trunk/WebCore/khtml/html/html_baseimpl.h
r9158 r9639 27 27 #define HTML_BASEIMPL_H 28 28 29 #include "html/dtd.h"30 29 #include "html/html_elementimpl.h" 31 30 #include "misc/khtmllayout.h" … … 56 55 ~HTMLBodyElementImpl(); 57 56 58 virtual Id id() const; 59 57 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 58 virtual int tagPriority() const { return 10; } 59 60 60 virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const; 61 61 virtual void parseMappedAttribute(MappedAttributeImpl *); … … 93 93 public: 94 94 HTMLFrameElementImpl(DocumentPtr *doc); 95 95 HTMLFrameElementImpl(const QualifiedName& tagName, DocumentPtr* doc); 96 96 ~HTMLFrameElementImpl(); 97 97 98 virtual Id id() const; 99 98 void init(); 99 100 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 101 virtual int tagPriority() const { return 0; } 102 100 103 virtual void parseMappedAttribute(MappedAttributeImpl *); 101 104 virtual void attach(); … … 169 172 public: 170 173 HTMLFrameSetElementImpl(DocumentPtr *doc); 171 172 174 ~HTMLFrameSetElementImpl(); 173 175 174 virtual Id id() const; 176 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 177 virtual int tagPriority() const { return 10; } 178 virtual bool checkDTD(const NodeImpl* newChild); 175 179 176 180 virtual void parseMappedAttribute(MappedAttributeImpl *); … … 217 221 public: 218 222 HTMLHeadElementImpl(DocumentPtr *doc); 219 220 223 ~HTMLHeadElementImpl(); 221 224 222 virtual Id id() const; 225 virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; } 226 virtual int tagPriority() const { return 10; } 227 virtual bool checkDTD(const NodeImpl* newChild); 223 228 224 229 DOMString profile() const; … … 234 239 ~HTMLHtmlElementImpl(); 235 240 236 virtual Id id() const; 241 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 242 virtual int tagPriority() const { return 11; } 243 virtual bool checkDTD(const NodeImpl* newChild); 237 244 238 245 DOMString version() const; … … 247 254 public: 248 255 HTMLIFrameElementImpl(DocumentPtr *doc); 249 250 256 ~HTMLIFrameElementImpl(); 251 257 252 virtual Id id() const; 258 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 259 virtual int tagPriority() const { return 1; } 253 260 254 261 virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const; -
trunk/WebCore/khtml/html/html_blockimpl.cpp
r9625 r9639 38 38 39 39 HTMLBlockquoteElementImpl::HTMLBlockquoteElementImpl(DocumentPtr *doc) 40 : HTMLElementImpl( doc)40 : HTMLElementImpl(HTMLNames::blockquote(), doc) 41 41 { 42 42 } … … 46 46 } 47 47 48 NodeImpl::Id HTMLBlockquoteElementImpl::id() const49 {50 return ID_BLOCKQUOTE;51 }52 53 48 DOMString HTMLBlockquoteElementImpl::cite() const 54 49 { … … 64 59 65 60 HTMLDivElementImpl::HTMLDivElementImpl(DocumentPtr *doc) 66 : HTMLElementImpl( doc)61 : HTMLElementImpl(HTMLNames::div(), doc) 67 62 { 68 63 } … … 70 65 HTMLDivElementImpl::~HTMLDivElementImpl() 71 66 { 72 }73 74 NodeImpl::Id HTMLDivElementImpl::id() const75 {76 return ID_DIV;77 67 } 78 68 … … 121 111 122 112 HTMLHRElementImpl::HTMLHRElementImpl(DocumentPtr *doc) 123 : HTMLElementImpl( doc)113 : HTMLElementImpl(HTMLNames::hr(), doc) 124 114 { 125 115 } … … 127 117 HTMLHRElementImpl::~HTMLHRElementImpl() 128 118 { 129 }130 131 NodeImpl::Id HTMLHRElementImpl::id() const132 {133 return ID_HR;134 119 } 135 120 … … 253 238 // ------------------------------------------------------------------------- 254 239 255 HTMLHeadingElementImpl::HTMLHeadingElementImpl(DocumentPtr *doc, ushort _tagid) 256 : HTMLGenericElementImpl(doc, _tagid) 257 { 240 HTMLHeadingElementImpl::HTMLHeadingElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 241 : HTMLElementImpl(tagName, doc) 242 { 243 } 244 245 bool HTMLHeadingElementImpl::checkDTD(const NodeImpl* newChild) 246 { 247 if (newChild->hasTagName(HTMLNames::h1()) || newChild->hasTagName(HTMLNames::h2()) || 248 newChild->hasTagName(HTMLNames::h3()) || newChild->hasTagName(HTMLNames::h4()) || 249 newChild->hasTagName(HTMLNames::h5()) || newChild->hasTagName(HTMLNames::h6())) 250 return false; 251 252 return inEitherTagList(newChild); 258 253 } 259 254 … … 271 266 272 267 HTMLParagraphElementImpl::HTMLParagraphElementImpl(DocumentPtr *doc) 273 : HTMLElementImpl( doc)274 { 275 } 276 277 NodeImpl::Id HTMLParagraphElementImpl::id() const 278 { 279 return ID_P;268 : HTMLElementImpl(HTMLNames::p(), doc) 269 { 270 } 271 272 bool HTMLParagraphElementImpl::checkDTD(const NodeImpl* newChild) 273 { 274 return inInlineTagList(newChild) || (getDocument()->inCompatMode() && newChild->hasTagName(HTMLNames::table())); 280 275 } 281 276 … … 323 318 // ------------------------------------------------------------------------- 324 319 325 HTMLPreElementImpl::HTMLPreElementImpl( DocumentPtr *doc, unsigned short _tagid)326 : HTML GenericElementImpl(doc, _tagid)320 HTMLPreElementImpl::HTMLPreElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 321 : HTMLElementImpl(tagName, doc) 327 322 { 328 323 } … … 344 339 345 340 HTMLMarqueeElementImpl::HTMLMarqueeElementImpl(DocumentPtr *doc) 346 : HTMLElementImpl( doc),341 : HTMLElementImpl(HTMLNames::marquee(), doc), 347 342 m_minimumDelay(defaultMinimumDelay) 348 343 { 349 }350 351 NodeImpl::Id HTMLMarqueeElementImpl::id() const352 {353 return ID_MARQUEE;354 344 } 355 345 … … 438 428 } 439 429 } 440 441 // ------------------------------------------------------------------------442 443 HTMLLayerElementImpl::HTMLLayerElementImpl(DocumentPtr *doc)444 : HTMLDivElementImpl( doc )445 {446 }447 448 HTMLLayerElementImpl::~HTMLLayerElementImpl()449 {450 }451 452 NodeImpl::Id HTMLLayerElementImpl::id() const453 {454 return ID_LAYER;455 } -
trunk/WebCore/khtml/html/html_blockimpl.h
r9158 r9639 27 27 28 28 #include "html_elementimpl.h" 29 #include "dtd.h"30 29 31 30 namespace DOM { … … 41 40 ~HTMLBlockquoteElementImpl(); 42 41 43 virtual Id id() const; 44 42 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 43 virtual int tagPriority() const { return 5; } 44 45 45 DOMString cite() const; 46 46 void setCite(const DOMString &); … … 56 56 HTMLDivElementImpl(DocumentPtr *doc); 57 57 ~HTMLDivElementImpl(); 58 59 virtual Id id() const; 58 59 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 60 virtual int tagPriority() const { return 5; } 60 61 61 62 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; … … 73 74 HTMLHRElementImpl(DocumentPtr *doc); 74 75 ~HTMLHRElementImpl(); 75 76 virtual Id id() const; 76 77 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 78 virtual int tagPriority() const { return 0; } 77 79 78 80 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; … … 94 96 // ------------------------------------------------------------------------- 95 97 96 class HTMLHeadingElementImpl : public HTML GenericElementImpl98 class HTMLHeadingElementImpl : public HTMLElementImpl 97 99 { 98 100 public: 99 HTMLHeadingElementImpl(DocumentPtr *doc, ushort _tagid); 101 HTMLHeadingElementImpl(const QualifiedName& tagName, DocumentPtr *doc); 102 103 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 104 virtual int tagPriority() const { return 5; } 105 virtual bool checkDTD(const NodeImpl* newChild); 100 106 101 107 DOMString align() const; … … 105 111 // ------------------------------------------------------------------------- 106 112 107 /*108 * were not using HTMLElementImpl as parent class, since a109 * paragraph should be able to flow around aligned objects. Thus110 * a <p> element has to be inline, and is rendered by111 * HTMLBlockImpl::calcParagraph112 */113 113 class HTMLParagraphElementImpl : public HTMLElementImpl 114 114 { … … 116 116 HTMLParagraphElementImpl(DocumentPtr *doc); 117 117 118 virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; } 119 virtual int tagPriority() const { return 3; } 120 virtual bool checkDTD(const NodeImpl* newChild); 121 118 122 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; 119 123 virtual void parseMappedAttribute(MappedAttributeImpl *attr); 120 121 virtual Id id() const;122 124 123 125 DOMString align() const; … … 127 129 // ------------------------------------------------------------------------- 128 130 129 class HTMLPreElementImpl : public HTML GenericElementImpl131 class HTMLPreElementImpl : public HTMLElementImpl 130 132 { 131 133 public: 132 HTMLPreElementImpl(DocumentPtr *doc, ushort _tagid); 134 HTMLPreElementImpl(const QualifiedName& tagName, DocumentPtr *doc); 135 136 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 137 virtual int tagPriority() const { return 5; } 133 138 134 139 long width() const; 135 void setWidth( long w);140 void setWidth(long w); 136 141 }; 137 142 … … 142 147 public: 143 148 HTMLMarqueeElementImpl(DocumentPtr *doc); 149 150 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 151 virtual int tagPriority() const { return 3; } 144 152 145 virtual Id id() const;146 147 153 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; 148 154 virtual void parseMappedAttribute(MappedAttributeImpl *token); … … 154 160 }; 155 161 156 // -------------------------------------------------------------------------157 158 class HTMLLayerElementImpl : public HTMLDivElementImpl159 {160 public:161 HTMLLayerElementImpl( DocumentPtr *doc );162 ~HTMLLayerElementImpl();163 164 virtual Id id() const;165 166 bool fixed;167 };168 169 162 }; //namespace 170 163 #endif -
trunk/WebCore/khtml/html/html_canvasimpl.cpp
r9158 r9639 56 56 57 57 HTMLCanvasElementImpl::HTMLCanvasElementImpl(DocumentPtr *doc) 58 : HTMLImageElementImpl( doc)58 : HTMLImageElementImpl(HTMLNames::canvas(), doc) 59 59 { 60 60 } … … 62 62 HTMLCanvasElementImpl::~HTMLCanvasElementImpl() 63 63 { 64 }65 66 NodeImpl::Id HTMLCanvasElementImpl::id() const67 {68 return ID_CANVAS;69 64 } 70 65 -
trunk/WebCore/khtml/html/html_canvasimpl.h
r9158 r9639 44 44 public: 45 45 HTMLCanvasElementImpl(DocumentPtr *doc); 46 47 46 ~HTMLCanvasElementImpl(); 48 49 virtual Id id() const;50 47 51 48 virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const; -
trunk/WebCore/khtml/html/html_documentimpl.cpp
r9156 r9639 61 61 #include "html/html_imageimpl.h" 62 62 #include "html/html_formimpl.h" 63 #include "htmlfactory.h" 63 64 64 65 #include "khtmlview.h" … … 247 248 { 248 249 // ### support comments. etc as a child 249 return (newChild->id() == ID_HTML || newChild->id() == ID_COMMENT); 250 } 251 252 ElementImpl *HTMLDocumentImpl::createElement( const DOMString &name, int &exceptioncode ) 253 { 254 return createHTMLElement(name, exceptioncode); 250 return (newChild->hasTagName(HTMLNames::html()) || newChild->isCommentNode()); 251 } 252 253 ElementImpl *HTMLDocumentImpl::createElement(const DOMString &name, int &exceptioncode) 254 { 255 // Do not check name validity. Other browsers don't, and it takes time. 256 DOMString lowerName(name.lower()); 257 return HTMLElementFactory::createHTMLElement(AtomicString(lowerName), this, 0, false); 255 258 } 256 259 -
trunk/WebCore/khtml/html/html_documentimpl.h
r9156 r9639 35 35 namespace DOM { 36 36 37 37 class HTMLElementImpl; 38 38 39 39 class HTMLDocumentImpl : public DOM::DocumentImpl, public khtml::CachedObjectClient -
trunk/WebCore/khtml/html/html_elementimpl.cpp
r9169 r9639 29 29 //#define UNSUPPORTED_ATTR 30 30 31 #include "html/dtd.h"32 31 #include "html/html_elementimpl.h" 33 32 #include "html/html_documentimpl.h" 34 33 #include "html/htmltokenizer.h" 34 #include "htmlfactory.h" 35 35 36 36 #include "misc/htmlhashes.h" 37 #include "misc/hashset.h" 37 38 #include "editing/visible_text.h" 38 39 … … 59 60 // ------------------------------------------------------------------ 60 61 61 HTMLElementImpl::HTMLElementImpl( DocumentPtr *doc)62 : StyledElementImpl( doc)62 HTMLElementImpl::HTMLElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 63 : StyledElementImpl(tagName, doc) 63 64 { 64 65 } … … 68 69 } 69 70 70 bool HTMLElementImpl::isInline() const 71 { 72 if (renderer()) 73 return ElementImpl::isInline(); 71 DOMString HTMLElementImpl::nodeName() const 72 { 73 // FIXME: Would be nice to have an atomicstring lookup based off uppercase chars that does not have to copy 74 // the string on a hit in the hash. 75 if (getDocument()->isHTMLDocument()) 76 return m_tagName.localName().implementation()->upper(); 77 return ElementImpl::nodeName(); 78 } 74 79 75 switch(id()) { 76 case ID_A: 77 case ID_FONT: 78 case ID_TT: 79 case ID_U: 80 case ID_B: 81 case ID_I: 82 case ID_S: 83 case ID_STRIKE: 84 case ID_BIG: 85 case ID_SMALL: 86 87 // %phrase 88 case ID_EM: 89 case ID_STRONG: 90 case ID_DFN: 91 case ID_CODE: 92 case ID_SAMP: 93 case ID_KBD: 94 case ID_VAR: 95 case ID_CITE: 96 case ID_ABBR: 97 case ID_ACRONYM: 98 99 // %special 100 case ID_SUB: 101 case ID_SUP: 102 case ID_SPAN: 103 case ID_NOBR: 104 case ID_WBR: 105 return true; 106 107 default: 108 return ElementImpl::isInline(); 109 } 80 HTMLTagStatus HTMLElementImpl::endTagRequirement() const 81 { 82 if (hasLocalName(HTMLNames::dt()) || hasLocalName(HTMLNames::dd())) 83 return TagStatusOptional; 84 85 // Same values as <span>. This way custom tag name elements will behave like inline spans. 86 return TagStatusRequired; 87 } 88 89 int HTMLElementImpl::tagPriority() const 90 { 91 if (hasLocalName(HTMLNames::address()) || hasLocalName(HTMLNames::dd()) || hasLocalName(HTMLNames::dt()) || hasLocalName(HTMLNames::noscript())) 92 return 3; 93 if (hasLocalName(HTMLNames::center()) || hasLocalName(HTMLNames::nobr())) 94 return 5; 95 if (hasLocalName(HTMLNames::noembed()) || hasLocalName(HTMLNames::noframes())) 96 return 10; 97 98 // Same values as <span>. This way custom tag name elements will behave like inline spans. 99 return 1; 110 100 } 111 101 112 102 NodeImpl *HTMLElementImpl::cloneNode(bool deep) 113 103 { 114 HTMLElementImpl *clone = static_cast<HTMLElementImpl *>(getDocument()->createHTMLElement(localNamePart(id())));104 HTMLElementImpl *clone = HTMLElementFactory::createHTMLElement(m_tagName.localName(), getDocument(), 0, false); 115 105 if (!clone) 116 106 return 0; … … 326 316 { 327 317 // the following is in accordance with the definition as used by IE 328 if( endTagRequirement(id()) == FORBIDDEN ) 329 return NULL; 330 // IE disallows innerHTML on inline elements. I don't see why we should have this restriction, as our 331 // dhtml engine can cope with it. Lars 332 //if ( isInline() ) return false; 333 switch( id() ) { 334 case ID_COL: 335 case ID_COLGROUP: 336 case ID_FRAMESET: 337 case ID_HEAD: 338 case ID_STYLE: 339 case ID_TITLE: 340 return NULL; 341 default: 342 break; 343 } 344 if ( !getDocument()->isHTMLDocument() ) 345 return NULL; 346 347 DocumentFragmentImpl *fragment = new DocumentFragmentImpl( docPtr() ); 318 if (endTagRequirement() == TagStatusForbidden) 319 return 0; 320 321 if (hasLocalName(HTMLNames::col()) || hasLocalName(HTMLNames::colgroup()) || hasLocalName(HTMLNames::frameset()) || 322 hasLocalName(HTMLNames::head()) || hasLocalName(HTMLNames::style()) || hasLocalName(HTMLNames::title())) 323 return 0; 324 325 if (!getDocument()->isHTMLDocument()) 326 return 0; 327 328 DocumentFragmentImpl *fragment = new DocumentFragmentImpl(docPtr()); 348 329 fragment->ref(); 349 330 { … … 359 340 360 341 // we need to pop <html> and <body> elements and remove <head> to 361 // accom adate folks passing complete HTML documents to make the342 // accommodate folks passing complete HTML documents to make the 362 343 // child of an element. 363 344 … … 366 347 nextNode = node->nextSibling(); 367 348 node->ref(); 368 if (node-> id() == ID_HTML || node->id() == ID_BODY) {349 if (node->hasTagName(HTMLNames::html()) || node->hasTagName(HTMLNames::body())) { 369 350 NodeImpl *firstChild = node->firstChild(); 370 351 if (firstChild != NULL) { … … 380 361 } 381 362 fragment->removeChild(node, ignoredExceptionCode); 382 } else if (node-> id() == ID_HEAD) {363 } else if (node->hasTagName(HTMLNames::head())) 383 364 fragment->removeChild(node, ignoredExceptionCode); 384 } 365 385 366 // Important to do this deref after removeChild, because if the only thing 386 367 // keeping a node around is a parent that is non-0, removeChild will not … … 401 382 void HTMLElementImpl::setInnerHTML(const DOMString &html, int &exception) 402 383 { 403 DocumentFragmentImpl *fragment = createContextualFragment( html);384 DocumentFragmentImpl *fragment = createContextualFragment(html); 404 385 if (fragment == NULL) { 405 386 exception = DOMException::NO_MODIFICATION_ALLOWED_ERR; … … 419 400 } 420 401 HTMLElementImpl *parent = static_cast<HTMLElementImpl *>(p); 421 DocumentFragmentImpl *fragment = parent->createContextualFragment( html);402 DocumentFragmentImpl *fragment = parent->createContextualFragment(html); 422 403 423 404 if (!fragment) { … … 435 416 { 436 417 // following the IE specs. 437 if (endTagRequirement( id()) == FORBIDDEN) {418 if (endTagRequirement() == TagStatusForbidden) { 438 419 exception = DOMException::NO_MODIFICATION_ALLOWED_ERR; 439 420 return; 440 421 } 441 422 442 // IE disallows innerText on inline elements. I don't see why we should have this restriction, as our 443 // dhtml engine can cope with it. Lars 444 //if ( isInline() ) return false; 445 switch( id() ) { 446 case ID_COL: 447 case ID_COLGROUP: 448 case ID_FRAMESET: 449 case ID_HEAD: 450 case ID_HTML: 451 case ID_TABLE: 452 case ID_TBODY: 453 case ID_TFOOT: 454 case ID_THEAD: 455 case ID_TR: 456 exception = DOMException::NO_MODIFICATION_ALLOWED_ERR; 457 return; 458 default: 459 break; 423 if (hasLocalName(HTMLNames::col()) || hasLocalName(HTMLNames::colgroup()) || hasLocalName(HTMLNames::frameset()) || 424 hasLocalName(HTMLNames::head()) || hasLocalName(HTMLNames::html()) || hasLocalName(HTMLNames::table()) || 425 hasLocalName(HTMLNames::tbody()) || hasLocalName(HTMLNames::tfoot()) || hasLocalName(HTMLNames::thead()) || 426 hasLocalName(HTMLNames::tr())) { 427 exception = DOMException::NO_MODIFICATION_ALLOWED_ERR; 428 return; 460 429 } 461 430 … … 467 436 { 468 437 // following the IE specs. 469 if ( endTagRequirement(id()) == FORBIDDEN) {438 if (endTagRequirement() == TagStatusForbidden) { 470 439 exception = DOMException::NO_MODIFICATION_ALLOWED_ERR; 471 440 return; 472 441 } 473 switch( id() ) { 474 case ID_COL: 475 case ID_COLGROUP: 476 case ID_FRAMESET: 477 case ID_HEAD: 478 case ID_HTML: 479 case ID_TABLE: 480 case ID_TBODY: 481 case ID_TFOOT: 482 case ID_THEAD: 483 case ID_TR: 484 exception = DOMException::NO_MODIFICATION_ALLOWED_ERR; 485 return; 486 default: 487 break; 442 443 if (hasLocalName(HTMLNames::col()) || hasLocalName(HTMLNames::colgroup()) || hasLocalName(HTMLNames::frameset()) || 444 hasLocalName(HTMLNames::head()) || hasLocalName(HTMLNames::html()) || hasLocalName(HTMLNames::table()) || 445 hasLocalName(HTMLNames::tbody()) || hasLocalName(HTMLNames::tfoot()) || hasLocalName(HTMLNames::thead()) || 446 hasLocalName(HTMLNames::tr())) { 447 exception = DOMException::NO_MODIFICATION_ALLOWED_ERR; 448 return; 488 449 } 489 450 … … 524 485 return; 525 486 } 526 }527 528 529 DOMString HTMLElementImpl::namespaceURI() const530 {531 // For HTML documents, we treat HTML elements as having no namespace. But for XML documents532 // the elements have the namespace defined in the XHTML spec533 if (getDocument()->isHTMLDocument())534 return DOMString();535 else536 return XHTML_NAMESPACE;537 487 } 538 488 … … 683 633 result += ">"; 684 634 685 if (endTagRequirement( id()) == REQUIRED) {635 if (endTagRequirement() == TagStatusRequired) { 686 636 result += "</"; 687 result += tagName();637 result += nodeName(); 688 638 result += ">"; 689 639 } … … 695 645 } 696 646 697 DOMString HTMLElementImpl::id DOM() const647 DOMString HTMLElementImpl::id() const 698 648 { 699 649 return getAttribute(ATTR_ID); … … 750 700 } 751 701 752 // ------------------------------------------------------------------------- 753 754 HTMLGenericElementImpl::HTMLGenericElementImpl(DocumentPtr *doc, ushort i) 755 : HTMLElementImpl(doc) 756 { 757 m_elementId = i; 758 } 759 760 NodeImpl::Id HTMLGenericElementImpl::id() const 761 { 762 return m_elementId; 763 } 702 // DOM Section 1.1.1 703 bool HTMLElementImpl::childAllowed(NodeImpl *newChild) 704 { 705 if (!ElementImpl::childAllowed(newChild)) 706 return false; 707 708 // For XML documents, we are non-validating and do not check against a DTD, even for HTML elements. 709 if (!getDocument()->isHTMLDocument()) 710 return true; 711 712 // Future-proof for XML content inside HTML documents (we may allow this some day). 713 if (newChild->isElementNode() && !newChild->isHTMLElement()) 714 return true; 715 716 // Elements with forbidden tag status can never have children 717 if (endTagRequirement() == TagStatusForbidden) 718 return false; 719 720 // Comment nodes are always allowed. 721 if (newChild->isCommentNode()) 722 return true; 723 724 // Now call checkDTD. 725 return checkDTD(newChild); 726 } 727 728 // DTD Stuff 729 // This unfortunate function is only needed when checking against the DTD. Other languages (like SVG) won't need this. 730 bool HTMLElementImpl::isRecognizedTagName(const QualifiedName& tagName) 731 { 732 static HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > tagList; 733 if (tagList.isEmpty()) { 734 tagList.insert(HTMLNames::a().localName().implementation()); 735 tagList.insert(HTMLNames::abbr().localName().implementation()); 736 tagList.insert(HTMLNames::acronym().localName().implementation()); 737 tagList.insert(HTMLNames::address().localName().implementation()); 738 tagList.insert(HTMLNames::applet().localName().implementation()); 739 tagList.insert(HTMLNames::area().localName().implementation()); 740 tagList.insert(HTMLNames::b().localName().implementation()); 741 tagList.insert(HTMLNames::base().localName().implementation()); 742 tagList.insert(HTMLNames::basefont().localName().implementation()); 743 tagList.insert(HTMLNames::bdo().localName().implementation()); 744 tagList.insert(HTMLNames::big().localName().implementation()); 745 tagList.insert(HTMLNames::blockquote().localName().implementation()); 746 tagList.insert(HTMLNames::body().localName().implementation()); 747 tagList.insert(HTMLNames::br().localName().implementation()); 748 tagList.insert(HTMLNames::button().localName().implementation()); 749 tagList.insert(HTMLNames::canvas().localName().implementation()); 750 tagList.insert(HTMLNames::caption().localName().implementation()); 751 tagList.insert(HTMLNames::center().localName().implementation()); 752 tagList.insert(HTMLNames::cite().localName().implementation()); 753 tagList.insert(HTMLNames::code().localName().implementation()); 754 tagList.insert(HTMLNames::col().localName().implementation()); 755 tagList.insert(HTMLNames::colgroup().localName().implementation()); 756 tagList.insert(HTMLNames::dd().localName().implementation()); 757 tagList.insert(HTMLNames::del().localName().implementation()); 758 tagList.insert(HTMLNames::dfn().localName().implementation()); 759 tagList.insert(HTMLNames::dir().localName().implementation()); 760 tagList.insert(HTMLNames::div().localName().implementation()); 761 tagList.insert(HTMLNames::dl().localName().implementation()); 762 tagList.insert(HTMLNames::dt().localName().implementation()); 763 tagList.insert(HTMLNames::em().localName().implementation()); 764 tagList.insert(HTMLNames::embed().localName().implementation()); 765 tagList.insert(HTMLNames::fieldset().localName().implementation()); 766 tagList.insert(HTMLNames::font().localName().implementation()); 767 tagList.insert(HTMLNames::form().localName().implementation()); 768 tagList.insert(HTMLNames::frame().localName().implementation()); 769 tagList.insert(HTMLNames::frameset().localName().implementation()); 770 tagList.insert(HTMLNames::head().localName().implementation()); 771 tagList.insert(HTMLNames::h1().localName().implementation()); 772 tagList.insert(HTMLNames::h2().localName().implementation()); 773 tagList.insert(HTMLNames::h3().localName().implementation()); 774 tagList.insert(HTMLNames::h4().localName().implementation()); 775 tagList.insert(HTMLNames::h5().localName().implementation()); 776 tagList.insert(HTMLNames::h6().localName().implementation()); 777 tagList.insert(HTMLNames::hr().localName().implementation()); 778 tagList.insert(HTMLNames::html().localName().implementation()); 779 tagList.insert(HTMLNames::i().localName().implementation()); 780 tagList.insert(HTMLNames::iframe().localName().implementation()); 781 tagList.insert(HTMLNames::img().localName().implementation()); 782 tagList.insert(HTMLNames::input().localName().implementation()); 783 tagList.insert(HTMLNames::ins().localName().implementation()); 784 tagList.insert(HTMLNames::isindex().localName().implementation()); 785 tagList.insert(HTMLNames::kbd().localName().implementation()); 786 tagList.insert(HTMLNames::keygen().localName().implementation()); 787 tagList.insert(HTMLNames::label().localName().implementation()); 788 tagList.insert(HTMLNames::layer().localName().implementation()); 789 tagList.insert(HTMLNames::legend().localName().implementation()); 790 tagList.insert(HTMLNames::li().localName().implementation()); 791 tagList.insert(HTMLNames::link().localName().implementation()); 792 tagList.insert(HTMLNames::map().localName().implementation()); 793 tagList.insert(HTMLNames::marquee().localName().implementation()); 794 tagList.insert(HTMLNames::menu().localName().implementation()); 795 tagList.insert(HTMLNames::meta().localName().implementation()); 796 tagList.insert(HTMLNames::nobr().localName().implementation()); 797 tagList.insert(HTMLNames::noembed().localName().implementation()); 798 tagList.insert(HTMLNames::noframes().localName().implementation()); 799 tagList.insert(HTMLNames::nolayer().localName().implementation()); 800 tagList.insert(HTMLNames::noscript().localName().implementation()); 801 tagList.insert(HTMLNames::object().localName().implementation()); 802 tagList.insert(HTMLNames::ol().localName().implementation()); 803 tagList.insert(HTMLNames::optgroup().localName().implementation()); 804 tagList.insert(HTMLNames::option().localName().implementation()); 805 tagList.insert(HTMLNames::p().localName().implementation()); 806 tagList.insert(HTMLNames::param().localName().implementation()); 807 tagList.insert(HTMLNames::plaintext().localName().implementation()); 808 tagList.insert(HTMLNames::pre().localName().implementation()); 809 tagList.insert(HTMLNames::q().localName().implementation()); 810 tagList.insert(HTMLNames::s().localName().implementation()); 811 tagList.insert(HTMLNames::samp().localName().implementation()); 812 tagList.insert(HTMLNames::script().localName().implementation()); 813 tagList.insert(HTMLNames::select().localName().implementation()); 814 tagList.insert(HTMLNames::small().localName().implementation()); 815 tagList.insert(HTMLNames::span().localName().implementation()); 816 tagList.insert(HTMLNames::strike().localName().implementation()); 817 tagList.insert(HTMLNames::strong().localName().implementation()); 818 tagList.insert(HTMLNames::style().localName().implementation()); 819 tagList.insert(HTMLNames::sub().localName().implementation()); 820 tagList.insert(HTMLNames::sup().localName().implementation()); 821 tagList.insert(HTMLNames::table().localName().implementation()); 822 tagList.insert(HTMLNames::tbody().localName().implementation()); 823 tagList.insert(HTMLNames::td().localName().implementation()); 824 tagList.insert(HTMLNames::textarea().localName().implementation()); 825 tagList.insert(HTMLNames::tfoot().localName().implementation()); 826 tagList.insert(HTMLNames::th().localName().implementation()); 827 tagList.insert(HTMLNames::thead().localName().implementation()); 828 tagList.insert(HTMLNames::title().localName().implementation()); 829 tagList.insert(HTMLNames::tr().localName().implementation()); 830 tagList.insert(HTMLNames::tt().localName().implementation()); 831 tagList.insert(HTMLNames::u().localName().implementation()); 832 tagList.insert(HTMLNames::ul().localName().implementation()); 833 tagList.insert(HTMLNames::var().localName().implementation()); 834 tagList.insert(HTMLNames::wbr().localName().implementation()); 835 tagList.insert(HTMLNames::xmp().localName().implementation()); 836 } 837 838 return tagList.contains(tagName.localName().implementation()); 839 } 840 841 // The terms inline and block are used here loosely. Don't make the mistake of assuming all inlines or all blocks 842 // need to be in these two lists. 843 HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> >* inlineTagList() { 844 static HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > tagList; 845 if (tagList.isEmpty()) { 846 tagList.insert(HTMLNames::tt().localName().implementation()); 847 tagList.insert(HTMLNames::i().localName().implementation()); 848 tagList.insert(HTMLNames::b().localName().implementation()); 849 tagList.insert(HTMLNames::u().localName().implementation()); 850 tagList.insert(HTMLNames::s().localName().implementation()); 851 tagList.insert(HTMLNames::strike().localName().implementation()); 852 tagList.insert(HTMLNames::big().localName().implementation()); 853 tagList.insert(HTMLNames::small().localName().implementation()); 854 tagList.insert(HTMLNames::em().localName().implementation()); 855 tagList.insert(HTMLNames::strong().localName().implementation()); 856 tagList.insert(HTMLNames::dfn().localName().implementation()); 857 tagList.insert(HTMLNames::code().localName().implementation()); 858 tagList.insert(HTMLNames::samp().localName().implementation()); 859 tagList.insert(HTMLNames::kbd().localName().implementation()); 860 tagList.insert(HTMLNames::var().localName().implementation()); 861 tagList.insert(HTMLNames::cite().localName().implementation()); 862 tagList.insert(HTMLNames::abbr().localName().implementation()); 863 tagList.insert(HTMLNames::acronym().localName().implementation()); 864 tagList.insert(HTMLNames::a().localName().implementation()); 865 tagList.insert(HTMLNames::canvas().localName().implementation()); 866 tagList.insert(HTMLNames::img().localName().implementation()); 867 tagList.insert(HTMLNames::applet().localName().implementation()); 868 tagList.insert(HTMLNames::object().localName().implementation()); 869 tagList.insert(HTMLNames::embed().localName().implementation()); 870 tagList.insert(HTMLNames::font().localName().implementation()); 871 tagList.insert(HTMLNames::basefont().localName().implementation()); 872 tagList.insert(HTMLNames::br().localName().implementation()); 873 tagList.insert(HTMLNames::script().localName().implementation()); 874 tagList.insert(HTMLNames::map().localName().implementation()); 875 tagList.insert(HTMLNames::q().localName().implementation()); 876 tagList.insert(HTMLNames::sub().localName().implementation()); 877 tagList.insert(HTMLNames::sup().localName().implementation()); 878 tagList.insert(HTMLNames::span().localName().implementation()); 879 tagList.insert(HTMLNames::bdo().localName().implementation()); 880 tagList.insert(HTMLNames::iframe().localName().implementation()); 881 tagList.insert(HTMLNames::input().localName().implementation()); 882 tagList.insert(HTMLNames::keygen().localName().implementation()); 883 tagList.insert(HTMLNames::select().localName().implementation()); 884 tagList.insert(HTMLNames::textarea().localName().implementation()); 885 tagList.insert(HTMLNames::label().localName().implementation()); 886 tagList.insert(HTMLNames::button().localName().implementation()); 887 tagList.insert(HTMLNames::ins().localName().implementation()); 888 tagList.insert(HTMLNames::del().localName().implementation()); 889 tagList.insert(HTMLNames::nobr().localName().implementation()); 890 tagList.insert(HTMLNames::wbr().localName().implementation()); 891 } 892 return &tagList; 893 } 894 895 HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> >* blockTagList() { 896 static HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > tagList; 897 if (tagList.isEmpty()) { 898 tagList.insert(HTMLNames::p().localName().implementation()); 899 tagList.insert(HTMLNames::h1().localName().implementation()); 900 tagList.insert(HTMLNames::h2().localName().implementation()); 901 tagList.insert(HTMLNames::h3().localName().implementation()); 902 tagList.insert(HTMLNames::h4().localName().implementation()); 903 tagList.insert(HTMLNames::h5().localName().implementation()); 904 tagList.insert(HTMLNames::h6().localName().implementation()); 905 tagList.insert(HTMLNames::ul().localName().implementation()); 906 tagList.insert(HTMLNames::ol().localName().implementation()); 907 tagList.insert(HTMLNames::dir().localName().implementation()); 908 tagList.insert(HTMLNames::menu().localName().implementation()); 909 tagList.insert(HTMLNames::pre().localName().implementation()); 910 tagList.insert(HTMLNames::plaintext().localName().implementation()); 911 tagList.insert(HTMLNames::xmp().localName().implementation()); 912 tagList.insert(HTMLNames::dl().localName().implementation()); 913 tagList.insert(HTMLNames::div().localName().implementation()); 914 tagList.insert(HTMLNames::layer().localName().implementation()); 915 tagList.insert(HTMLNames::center().localName().implementation()); 916 tagList.insert(HTMLNames::noscript().localName().implementation()); 917 tagList.insert(HTMLNames::noframes().localName().implementation()); 918 tagList.insert(HTMLNames::blockquote().localName().implementation()); 919 tagList.insert(HTMLNames::form().localName().implementation()); 920 tagList.insert(HTMLNames::isindex().localName().implementation()); 921 tagList.insert(HTMLNames::hr().localName().implementation()); 922 tagList.insert(HTMLNames::table().localName().implementation()); 923 tagList.insert(HTMLNames::fieldset().localName().implementation()); 924 tagList.insert(HTMLNames::address().localName().implementation()); 925 tagList.insert(HTMLNames::li().localName().implementation()); 926 tagList.insert(HTMLNames::dd().localName().implementation()); 927 tagList.insert(HTMLNames::dt().localName().implementation()); 928 tagList.insert(HTMLNames::marquee().localName().implementation()); 929 } 930 return &tagList; 931 } 932 933 bool HTMLElementImpl::inEitherTagList(const NodeImpl* newChild) 934 { 935 if (newChild->isTextNode()) 936 return true; 937 938 if (newChild->isHTMLElement()) { 939 const HTMLElementImpl* child = static_cast<const HTMLElementImpl*>(newChild); 940 if (inlineTagList()->contains(child->tagName().localName().implementation())) 941 return true; 942 if (blockTagList()->contains(child->tagName().localName().implementation())) 943 return true; 944 return !isRecognizedTagName(child->tagName()); // Accept custom html tags 945 } 946 947 return false; 948 } 949 950 bool HTMLElementImpl::inInlineTagList(const NodeImpl* newChild) 951 { 952 if (newChild->isTextNode()) 953 return true; 954 955 if (newChild->isHTMLElement()) { 956 const HTMLElementImpl* child = static_cast<const HTMLElementImpl*>(newChild); 957 if (inlineTagList()->contains(child->tagName().localName().implementation())) 958 return true; 959 return !isRecognizedTagName(child->tagName()); // Accept custom html tags 960 } 961 962 return false; 963 } 964 965 bool HTMLElementImpl::inBlockTagList(const NodeImpl* newChild) 966 { 967 if (newChild->isTextNode()) 968 return true; 969 970 if (newChild->isHTMLElement()) { 971 const HTMLElementImpl* child = static_cast<const HTMLElementImpl*>(newChild); 972 return (blockTagList()->contains(child->tagName().localName().implementation())); 973 } 974 975 return false; 976 } 977 978 bool HTMLElementImpl::checkDTD(const NodeImpl* newChild) 979 { 980 if (hasTagName(HTMLNames::address()) && newChild->hasTagName(HTMLNames::p())) 981 return true; 982 return inEitherTagList(newChild); 983 } -
trunk/WebCore/khtml/html/html_elementimpl.h
r9158 r9639 26 26 27 27 #include "xml/dom_elementimpl.h" 28 #include <qptrdict.h>28 #include "htmlnames.h" 29 29 30 30 namespace DOM { … … 33 33 class DOMString; 34 34 class HTMLCollectionImpl; 35 35 36 enum HTMLTagStatus { TagStatusOptional, TagStatusRequired, TagStatusForbidden }; 37 36 38 class HTMLElementImpl : public StyledElementImpl 37 39 { 38 40 public: 39 HTMLElementImpl(DocumentPtr *doc); 40 41 HTMLElementImpl(const QualifiedName& tagName, DocumentPtr *doc); 41 42 virtual ~HTMLElementImpl(); 42 43 43 44 virtual bool isHTMLElement() const { return true; } 44 45 45 virtual bool isInline() const; 46 47 virtual Id id() const = 0; 48 46 virtual DOMString nodeName() const; 47 49 48 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; 50 49 virtual void parseMappedAttribute(MappedAttributeImpl* attr); … … 54 53 SharedPtr<HTMLCollectionImpl> children(); 55 54 56 DOMString id DOM() const; // rename to id after eliminating NodeImpl::id some day55 DOMString id() const; 57 56 void setId(const DOMString &value); 58 57 DOMString title() const; … … 74 73 void setInnerText(const DOMString &text, int &exception); 75 74 void setOuterText(const DOMString &text, int &exception); 76 77 virtual DOMString namespaceURI() const;78 75 79 76 virtual bool isFocusable() const; … … 90 87 virtual DOMString toString() const; 91 88 89 virtual HTMLTagStatus endTagRequirement() const; 90 virtual int tagPriority() const; 91 virtual bool childAllowed(NodeImpl* newChild); // Error-checking during parsing that checks the DTD 92 93 // Helper function to check the DTD for a given child node. 94 virtual bool checkDTD(const NodeImpl* newChild); 95 static bool inEitherTagList(const NodeImpl* newChild); 96 static bool inInlineTagList(const NodeImpl* newChild); 97 static bool inBlockTagList(const NodeImpl* newChild); 98 static bool isRecognizedTagName(const QualifiedName& tagName); 99 92 100 protected: 93 101 … … 96 104 }; 97 105 98 class HTMLGenericElementImpl : public HTMLElementImpl99 {100 public:101 HTMLGenericElementImpl(DocumentPtr *doc, ushort elementId);102 virtual Id id() const;103 104 protected:105 ushort m_elementId;106 };107 108 106 } //namespace 109 107 -
trunk/WebCore/khtml/html/html_formimpl.cpp
r9524 r9639 104 104 105 105 HTMLFormElementImpl::HTMLFormElementImpl(DocumentPtr *doc) 106 : HTMLElementImpl( doc)106 : HTMLElementImpl(HTMLNames::form(), doc) 107 107 { 108 108 collectionInfo = 0; … … 131 131 } 132 132 133 NodeImpl::Id HTMLFormElementImpl::id() const134 {135 return ID_FORM;136 }137 138 133 #if APPLE_CHANGES 139 134 … … 193 188 bool submitFound = false; 194 189 for (unsigned i = 0; i < formElements.count(); ++i) { 195 if (formElements[i]-> id() == ID_INPUT) {190 if (formElements[i]->hasLocalName(HTMLNames::input())) { 196 191 HTMLInputElementImpl *element = static_cast<HTMLInputElementImpl *>(formElements[i]); 197 192 if (element->isSuccessfulSubmitButton() && element->renderer()) { … … 400 395 // if the current type is FILE, then we also need to 401 396 // include the filename 402 if (current-> nodeType() == Node::ELEMENT_NODE && current->id() == ID_INPUT&&397 if (current->hasLocalName(HTMLNames::input()) && 403 398 static_cast<HTMLInputElementImpl*>(current)->inputType() == HTMLInputElementImpl::FILE) 404 399 { … … 548 543 // Our app needs to get form values for password fields for doing password autocomplete, 549 544 // so we are more lenient in pushing values, and let the app decide what to save when. 550 if (current-> id() == ID_INPUT) {545 if (current->hasLocalName(HTMLNames::input())) { 551 546 HTMLInputElementImpl *input = static_cast<HTMLInputElementImpl*>(current); 552 547 if (input->inputType() == HTMLInputElementImpl::TEXT … … 710 705 for (unsigned i = 0; i < formElements.count(); ++i) { 711 706 HTMLGenericFormElementImpl *current = formElements[i]; 712 if (current-> id() == ID_INPUT&&707 if (current->hasLocalName(HTMLNames::input()) && 713 708 static_cast<HTMLInputElementImpl*>(current)->inputType() == HTMLInputElementImpl::RADIO && 714 709 current != caller && current->form() == caller->form() && current->name() == caller->name()) { … … 865 860 // ------------------------------------------------------------------------- 866 861 867 HTMLGenericFormElementImpl::HTMLGenericFormElementImpl( DocumentPtr *doc, HTMLFormElementImpl *f)868 : HTMLElementImpl( doc)862 HTMLGenericFormElementImpl::HTMLGenericFormElementImpl(const QualifiedName& tagName, DocumentPtr *doc, HTMLFormElementImpl *f) 863 : HTMLElementImpl(tagName, doc) 869 864 { 870 865 m_disabled = m_readOnly = false; … … 968 963 { 969 964 NodeImpl *p = parentNode(); 970 while(p) 971 { 972 if( p->id() == ID_FORM ) 965 while(p) { 966 if (p->hasTagName(HTMLNames::form())) 973 967 return static_cast<HTMLFormElementImpl *>(p); 974 968 p = p->parentNode(); … … 1190 1184 1191 1185 HTMLButtonElementImpl::HTMLButtonElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 1192 : HTMLGenericFormElementImpl( doc, f)1186 : HTMLGenericFormElementImpl(HTMLNames::button(), doc, f) 1193 1187 { 1194 1188 m_type = SUBMIT; … … 1199 1193 HTMLButtonElementImpl::~HTMLButtonElementImpl() 1200 1194 { 1201 }1202 1203 NodeImpl::Id HTMLButtonElementImpl::id() const1204 {1205 return ID_BUTTON;1206 1195 } 1207 1196 … … 1327 1316 1328 1317 HTMLFieldSetElementImpl::HTMLFieldSetElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 1329 : HTMLGenericFormElementImpl( doc, f)1318 : HTMLGenericFormElementImpl(HTMLNames::fieldset(), doc, f) 1330 1319 { 1331 1320 } … … 1335 1324 } 1336 1325 1326 bool HTMLFieldSetElementImpl::checkDTD(const NodeImpl* newChild) 1327 { 1328 return newChild->hasTagName(HTMLNames::legend()) || HTMLElementImpl::checkDTD(newChild); 1329 } 1330 1337 1331 bool HTMLFieldSetElementImpl::isFocusable() const 1338 1332 { … … 1340 1334 } 1341 1335 1342 NodeImpl::Id HTMLFieldSetElementImpl::id() const1343 {1344 return ID_FIELDSET;1345 }1346 1347 1336 DOMString HTMLFieldSetElementImpl::type() const 1348 1337 { … … 1358 1347 1359 1348 HTMLInputElementImpl::HTMLInputElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 1360 : HTMLGenericFormElementImpl(doc, f), m_imageLoader(0), m_valueMatchesRenderer(false) 1361 { 1349 : HTMLGenericFormElementImpl(HTMLNames::input(), doc, f) 1350 { 1351 init(); 1352 } 1353 1354 HTMLInputElementImpl::HTMLInputElementImpl(const QualifiedName& tagName, DocumentPtr *doc, HTMLFormElementImpl *f) 1355 : HTMLGenericFormElementImpl(tagName, doc, f) 1356 { 1357 init(); 1358 } 1359 1360 void HTMLInputElementImpl::init() 1361 { 1362 m_imageLoader = 0; 1363 m_valueMatchesRenderer = false; 1362 1364 m_type = TEXT; 1363 1365 m_maxLen = -1; … … 1377 1379 m_maxResults = -1; 1378 1380 1379 if ( m_form)1380 m_autocomplete = f->autoComplete();1381 if (m_form) 1382 m_autocomplete = m_form->autoComplete(); 1381 1383 } 1382 1384 … … 1385 1387 if (getDocument()) getDocument()->deregisterMaintainsState(this); 1386 1388 delete m_imageLoader; 1387 }1388 1389 NodeImpl::Id HTMLInputElementImpl::id() const1390 {1391 return ID_INPUT;1392 1389 } 1393 1390 … … 2469 2466 2470 2467 HTMLLabelElementImpl::HTMLLabelElementImpl(DocumentPtr *doc) 2471 : HTMLElementImpl( doc)2468 : HTMLElementImpl(HTMLNames::label(), doc) 2472 2469 { 2473 2470 } … … 2480 2477 { 2481 2478 return false; 2482 }2483 2484 NodeImpl::Id HTMLLabelElementImpl::id() const2485 {2486 return ID_LABEL;2487 2479 } 2488 2480 … … 2540 2532 { 2541 2533 for (NodeImpl *p = parentNode(); p != 0; p = p->parentNode()) { 2542 if (p-> id() == ID_FORM)2534 if (p->hasTagName(HTMLNames::form())) 2543 2535 return static_cast<HTMLFormElementImpl *>(p); 2544 2536 } … … 2570 2562 2571 2563 HTMLLegendElementImpl::HTMLLegendElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 2572 : HTMLGenericFormElementImpl( doc, f)2564 : HTMLGenericFormElementImpl(HTMLNames::legend(), doc, f) 2573 2565 { 2574 2566 } … … 2581 2573 { 2582 2574 return false; 2583 }2584 2585 NodeImpl::Id HTMLLegendElementImpl::id() const2586 {2587 return ID_LEGEND;2588 2575 } 2589 2576 … … 2622 2609 // Check if there's a fieldset belonging to this legend. 2623 2610 NodeImpl *fieldset = parentNode(); 2624 while (fieldset && fieldset->id() != ID_FIELDSET)2611 while (fieldset && !fieldset->hasTagName(HTMLNames::fieldset())) 2625 2612 fieldset = fieldset->parentNode(); 2626 2613 if (!fieldset) … … 2633 2620 if (node->isHTMLElement()) { 2634 2621 HTMLElementImpl *element = static_cast<HTMLElementImpl *>(node); 2635 if ( element->id() != ID_LEGEND&& element->isGenericFormElement())2622 if (!element->hasLocalName(HTMLNames::legend()) && element->isGenericFormElement()) 2636 2623 return element; 2637 2624 } … … 2656 2643 2657 2644 HTMLSelectElementImpl::HTMLSelectElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 2658 : HTMLGenericFormElementImpl(doc, f), m_options(0) 2659 { 2645 : HTMLGenericFormElementImpl(HTMLNames::select(), doc, f), m_options(0) 2646 { 2647 init(); 2648 } 2649 2650 HTMLSelectElementImpl::HTMLSelectElementImpl(const QualifiedName& tagName, DocumentPtr *doc, HTMLFormElementImpl *f) 2651 : HTMLGenericFormElementImpl(tagName, doc, f), m_options(0) 2652 { 2653 init(); 2654 } 2655 2656 void HTMLSelectElementImpl::init() 2657 { 2658 m_options = 0; 2660 2659 m_multiple = false; 2661 2660 m_recalcListItems = false; … … 2674 2673 } 2675 2674 2676 NodeImpl::Id HTMLSelectElementImpl::id() const 2677 { 2678 return ID_SELECT; 2675 bool HTMLSelectElementImpl::checkDTD(const NodeImpl* newChild) 2676 { 2677 return newChild->isTextNode() || newChild->hasTagName(HTMLNames::option()) || newChild->hasTagName(HTMLNames::optgroup()) || 2678 newChild->hasTagName(HTMLNames::script()); 2679 2679 } 2680 2680 … … 2700 2700 QMemArray<HTMLGenericFormElementImpl*> items = listItems(); 2701 2701 for (unsigned int i = 0; i < items.size(); i++) { 2702 if (items[i]-> id() == ID_OPTION) {2702 if (items[i]->hasLocalName(HTMLNames::option())) { 2703 2703 if (static_cast<HTMLOptionElementImpl*>(items[i])->selected()) 2704 2704 return o; … … 2716 2716 int listIndex; 2717 2717 for (listIndex = 0; listIndex < int(items.size()); listIndex++) { 2718 if (items[listIndex]-> id() == ID_OPTION)2718 if (items[listIndex]->hasLocalName(HTMLNames::option())) 2719 2719 static_cast<HTMLOptionElementImpl*>(items[listIndex])->setSelected(false); 2720 2720 } … … 2732 2732 QMemArray<HTMLGenericFormElementImpl*> items = listItems(); 2733 2733 for (i = 0; i < items.size(); i++) { 2734 if (items[i]-> id() == ID_OPTION)2734 if (items[i]->hasLocalName(HTMLNames::option())) 2735 2735 len++; 2736 2736 } … … 2740 2740 void HTMLSelectElementImpl::add( HTMLElementImpl *element, HTMLElementImpl *before ) 2741 2741 { 2742 if (!element || element->id() != ID_OPTION)2742 if (!element || !element->hasLocalName(HTMLNames::option())) 2743 2743 return; 2744 2744 … … 2774 2774 } 2775 2775 2776 DOMString HTMLSelectElementImpl::value( 2776 DOMString HTMLSelectElementImpl::value() 2777 2777 { 2778 2778 uint i; 2779 2779 QMemArray<HTMLGenericFormElementImpl*> items = listItems(); 2780 2780 for (i = 0; i < items.size(); i++) { 2781 if ( items[i]->id() == ID_OPTION 2782 && static_cast<HTMLOptionElementImpl*>(items[i])->selected()) 2781 if (items[i]->hasLocalName(HTMLNames::option()) && static_cast<HTMLOptionElementImpl*>(items[i])->selected()) 2783 2782 return static_cast<HTMLOptionElementImpl*>(items[i])->value(); 2784 2783 } … … 2794 2793 QMemArray<HTMLGenericFormElementImpl*> items = listItems(); 2795 2794 for (unsigned i = 0; i < items.size(); i++) 2796 if (items[i]-> id() == ID_OPTION&& static_cast<HTMLOptionElementImpl*>(items[i])->value() == value) {2795 if (items[i]->hasLocalName(HTMLNames::option()) && static_cast<HTMLOptionElementImpl*>(items[i])->value() == value) { 2797 2796 static_cast<HTMLOptionElementImpl*>(items[i])->setSelected(true); 2798 2797 return; … … 2800 2799 } 2801 2800 2802 QString HTMLSelectElementImpl::state( 2801 QString HTMLSelectElementImpl::state() 2803 2802 { 2804 2803 #if !APPLE_CHANGES … … 2813 2812 2814 2813 for(int i = 0; i < l; i++) 2815 if(items[i]-> id() == ID_OPTION&& static_cast<HTMLOptionElementImpl*>(items[i])->selected())2814 if(items[i]->hasLocalName(HTMLNames::option()) && static_cast<HTMLOptionElementImpl*>(items[i])->selected()) 2816 2815 stateChars[i] = 'X'; 2817 2816 else … … 2850 2849 int l = items.count(); 2851 2850 for(int i = 0; i < l; i++) { 2852 if(items[i]-> id() == ID_OPTION) {2851 if(items[i]->hasLocalName(HTMLNames::option())) { 2853 2852 HTMLOptionElementImpl* oe = static_cast<HTMLOptionElementImpl*>(items[i]); 2854 2853 oe->setSelected(state[i] == 'X'); … … 2942 2941 uint i; 2943 2942 for (i = 0; i < items.size(); i++) { 2944 if (items[i]-> id() == ID_OPTION) {2943 if (items[i]->hasLocalName(HTMLNames::option())) { 2945 2944 HTMLOptionElementImpl *option = static_cast<HTMLOptionElementImpl*>(items[i]); 2946 2945 if (option->selected()) { … … 2955 2954 // we return the first one if it was a combobox select 2956 2955 if (!successful && !m_multiple && m_size <= 1 && items.size() && 2957 (items[0]-> id() == ID_OPTION)) {2956 (items[0]->hasLocalName(HTMLNames::option()))) { 2958 2957 HTMLOptionElementImpl *option = static_cast<HTMLOptionElementImpl*>(items[0]); 2959 2958 if (option->value().isNull()) … … 2978 2977 optionIndex2 < int(items.size()) && optionIndex2 <= optionIndex; 2979 2978 listIndex++) { // not a typo! 2980 if (items[listIndex]-> id() == ID_OPTION)2979 if (items[listIndex]->hasLocalName(HTMLNames::option())) 2981 2980 optionIndex2++; 2982 2981 } … … 2989 2988 QMemArray<HTMLGenericFormElementImpl*> items = listItems(); 2990 2989 if (listIndex < 0 || listIndex >= int(items.size()) || 2991 items[listIndex]->id() != ID_OPTION)2990 !items[listIndex]->hasLocalName(HTMLNames::option())) 2992 2991 return -1; 2993 2992 … … 2995 2994 int i; 2996 2995 for (i = 0; i < listIndex; i++) 2997 if (items[i]-> id() == ID_OPTION)2996 if (items[i]->hasLocalName(HTMLNames::option())) 2998 2997 optionIndex++; 2999 2998 return optionIndex; … … 3021 3020 HTMLOptionElementImpl* foundSelected = 0; 3022 3021 while(current) { 3023 if (current-> id() == ID_OPTGROUP&& current->firstChild()) {3022 if (current->hasTagName(HTMLNames::optgroup()) && current->firstChild()) { 3024 3023 // ### what if optgroup contains just comments? don't want one of no options in it... 3025 3024 m_listItems.resize(m_listItems.size()+1); … … 3027 3026 current = current->firstChild(); 3028 3027 } 3029 if (current-> id() == ID_OPTION) {3028 if (current->hasTagName(HTMLNames::option())) { 3030 3029 m_listItems.resize(m_listItems.size()+1); 3031 3030 m_listItems[m_listItems.size()-1] = static_cast<HTMLGenericFormElementImpl*>(current); … … 3069 3068 uint i; 3070 3069 for (i = 0; i < items.size(); i++) { 3071 if (items[i]-> id() == ID_OPTION) {3070 if (items[i]->hasLocalName(HTMLNames::option())) { 3072 3071 HTMLOptionElementImpl *option = static_cast<HTMLOptionElementImpl*>(items[i]); 3073 3072 bool selected = (!option->getAttribute(ATTR_SELECTED).isNull()); … … 3087 3086 uint i; 3088 3087 for (i = 0; i < items.size(); i++) { 3089 if (items[i]-> id() == ID_OPTION)3088 if (items[i]->hasLocalName(HTMLNames::option())) 3090 3089 static_cast<HTMLOptionElementImpl*>(items[i])->m_selected = (items[i] == selectedOption); 3091 3090 } … … 3134 3133 3135 3134 HTMLKeygenElementImpl::HTMLKeygenElementImpl(DocumentPtr* doc, HTMLFormElementImpl* f) 3136 : HTMLSelectElementImpl( doc, f)3135 : HTMLSelectElementImpl(HTMLNames::keygen(), doc, f) 3137 3136 { 3138 3137 QStringList keys = KSSLKeyGen::supportedKeySizes(); … … 3144 3143 } 3145 3144 3146 NodeImpl::Id HTMLKeygenElementImpl::id() const3147 {3148 return ID_KEYGEN;3149 }3150 3151 3145 DOMString HTMLKeygenElementImpl::type() const 3152 3146 { … … 3203 3197 3204 3198 HTMLOptGroupElementImpl::HTMLOptGroupElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 3205 : HTMLGenericFormElementImpl( doc, f)3199 : HTMLGenericFormElementImpl(HTMLNames::optgroup(), doc, f) 3206 3200 { 3207 3201 } … … 3214 3208 { 3215 3209 return false; 3216 }3217 3218 NodeImpl::Id HTMLOptGroupElementImpl::id() const3219 {3220 return ID_OPTGROUP;3221 3210 } 3222 3211 … … 3274 3263 { 3275 3264 NodeImpl *select = parentNode(); 3276 while (select && select->id() != ID_SELECT)3265 while (select && !select->hasTagName(HTMLNames::select())) 3277 3266 select = select->parentNode(); 3278 3267 if (select) … … 3293 3282 3294 3283 HTMLOptionElementImpl::HTMLOptionElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 3295 : HTMLGenericFormElementImpl( doc, f)3284 : HTMLGenericFormElementImpl(HTMLNames::option(), doc, f) 3296 3285 { 3297 3286 m_selected = false; … … 3301 3290 { 3302 3291 return false; 3303 }3304 3305 NodeImpl::Id HTMLOptionElementImpl::id() const3306 {3307 return ID_OPTION;3308 3292 } 3309 3293 … … 3354 3338 int optionIndex = 0; 3355 3339 for(int i = 0; i < l; i++) { 3356 if(items[i]->id() == ID_OPTION) 3357 { 3340 if (items[i]->hasLocalName(HTMLNames::option())) { 3358 3341 if (static_cast<HTMLOptionElementImpl*>(items[i]) == this) 3359 3342 return optionIndex; … … 3420 3403 { 3421 3404 NodeImpl *select = parentNode(); 3422 while (select && select->id() != ID_SELECT)3405 while (select && !select->hasTagName(HTMLNames::select())) 3423 3406 select = select->parentNode(); 3424 3407 return static_cast<HTMLSelectElementImpl*>(select); … … 3448 3431 3449 3432 HTMLTextAreaElementImpl::HTMLTextAreaElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 3450 : HTMLGenericFormElementImpl( doc, f), m_valueIsValid(false), m_valueMatchesRenderer(false)3433 : HTMLGenericFormElementImpl(HTMLNames::textarea(), doc, f), m_valueIsValid(false), m_valueMatchesRenderer(false) 3451 3434 { 3452 3435 // DTD requires rows & cols be specified, but we will provide reasonable defaults … … 3459 3442 { 3460 3443 if (getDocument()) getDocument()->deregisterMaintainsState(this); 3461 }3462 3463 NodeImpl::Id HTMLTextAreaElementImpl::id() const3464 {3465 return ID_TEXTAREA;3466 3444 } 3467 3445 … … 3715 3693 3716 3694 HTMLIsIndexElementImpl::HTMLIsIndexElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 3717 : HTMLInputElementImpl( doc, f)3695 : HTMLInputElementImpl(HTMLNames::isindex(), doc, f) 3718 3696 { 3719 3697 m_type = TEXT; 3720 3698 setOverrideName("isindex"); 3721 }3722 3723 NodeImpl::Id HTMLIsIndexElementImpl::id() const3724 {3725 return ID_ISINDEX;3726 3699 } 3727 3700 -
trunk/WebCore/khtml/html/html_formimpl.h
r9479 r9639 68 68 virtual ~HTMLFormElementImpl(); 69 69 70 virtual Id id() const; 70 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 71 virtual int tagPriority() const { return 3; } 71 72 72 73 virtual void attach(); … … 162 163 163 164 public: 164 HTMLGenericFormElementImpl( DocumentPtr *doc, HTMLFormElementImpl *f = 0);165 HTMLGenericFormElementImpl(const QualifiedName& tagName, DocumentPtr *doc, HTMLFormElementImpl *f = 0); 165 166 virtual ~HTMLGenericFormElementImpl(); 167 168 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 169 virtual int tagPriority() const { return 1; } 166 170 167 171 HTMLFormElementImpl *form() { return m_form; } … … 236 240 public: 237 241 HTMLButtonElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0); 238 239 242 virtual ~HTMLButtonElementImpl(); 240 243 … … 245 248 }; 246 249 247 virtual Id id() const;248 250 DOMString type() const; 249 251 … … 281 283 public: 282 284 HTMLFieldSetElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0); 283 284 285 virtual ~HTMLFieldSetElementImpl(); 285 286 virtual Id id() const; 287 286 287 virtual int tagPriority() const { return 3; } 288 virtual bool checkDTD(const NodeImpl* newChild); 289 288 290 virtual bool isFocusable() const; 289 291 … … 327 329 328 330 HTMLInputElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0); 331 HTMLInputElementImpl(const QualifiedName& tagName, DocumentPtr *doc, HTMLFormElementImpl *f = 0); 329 332 virtual ~HTMLInputElementImpl(); 330 331 virtual Id id() const; 333 void init(); 334 335 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 336 virtual int tagPriority() const { return 0; } 332 337 333 338 virtual bool isEnumeratable() const { return inputType() != IMAGE; } … … 460 465 virtual ~HTMLLabelElementImpl(); 461 466 467 virtual int tagPriority() const { return 5; } 468 462 469 virtual bool isFocusable() const; 463 464 virtual Id id() const;465 470 466 471 virtual void parseMappedAttribute(MappedAttributeImpl *attr); … … 497 502 virtual bool isFocusable() const; 498 503 499 virtual Id id() const;500 504 virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *); 501 505 … … 526 530 public: 527 531 HTMLSelectElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0); 532 HTMLSelectElementImpl(const QualifiedName& tagName, DocumentPtr *doc, HTMLFormElementImpl *f = 0); 528 533 ~HTMLSelectElementImpl(); 529 530 virtual Id id() const; 534 void init(); 535 536 virtual int tagPriority() const { return 6; } 537 virtual bool checkDTD(const NodeImpl* newChild); 538 531 539 DOMString type() const; 532 540 … … 615 623 HTMLKeygenElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0); 616 624 617 virtual Id id() const;625 virtual int tagPriority() const { return 0; } 618 626 619 627 DOMString type() const; … … 637 645 virtual ~HTMLOptGroupElementImpl(); 638 646 639 virtual Id id() const; 647 virtual bool checkDTD(const NodeImpl* newChild) { return newChild->hasTagName(HTMLNames::option()); } 648 640 649 DOMString type() const; 641 650 … … 665 674 HTMLOptionElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0); 666 675 676 virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; } 677 virtual int tagPriority() const { return 2; } 678 virtual bool checkDTD(const NodeImpl* newChild) { return newChild->isTextNode(); } 679 667 680 virtual bool isFocusable() const; 668 669 virtual Id id() const; 681 670 682 DOMString type() const; 671 683 … … 715 727 ~HTMLTextAreaElementImpl(); 716 728 717 virtual Id id() const;729 virtual bool checkDTD(const NodeImpl* newChild) { return newChild->isTextNode(); } 718 730 719 731 long cols() const { return m_cols; } 720 721 732 long rows() const { return m_rows; } 722 733 … … 786 797 HTMLIsIndexElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0); 787 798 788 virtual Id id() const; 799 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 800 virtual int tagPriority() const { return 0; } 789 801 790 802 virtual void parseMappedAttribute(MappedAttributeImpl *attr); -
trunk/WebCore/khtml/html/html_headimpl.cpp
r9466 r9639 47 47 48 48 HTMLBaseElementImpl::HTMLBaseElementImpl(DocumentPtr *doc) 49 : HTMLElementImpl( doc)49 : HTMLElementImpl(HTMLNames::base(), doc) 50 50 { 51 51 } … … 53 53 HTMLBaseElementImpl::~HTMLBaseElementImpl() 54 54 { 55 }56 57 NodeImpl::Id HTMLBaseElementImpl::id() const58 {59 return ID_BASE;60 55 } 61 56 … … 120 115 121 116 HTMLLinkElementImpl::HTMLLinkElementImpl(DocumentPtr *doc) 122 : HTMLElementImpl( doc)117 : HTMLElementImpl(HTMLNames::link(), doc) 123 118 { 124 119 m_sheet = 0; … … 133 128 if(m_sheet) m_sheet->deref(); 134 129 if(m_cachedSheet) m_cachedSheet->deref(this); 135 }136 137 NodeImpl::Id HTMLLinkElementImpl::id() const138 {139 return ID_LINK;140 130 } 141 131 … … 424 414 // ------------------------------------------------------------------------- 425 415 426 HTMLMetaElementImpl::HTMLMetaElementImpl(DocumentPtr *doc) : HTMLElementImpl( doc)416 HTMLMetaElementImpl::HTMLMetaElementImpl(DocumentPtr *doc) : HTMLElementImpl(HTMLNames::meta(), doc) 427 417 { 428 418 } … … 430 420 HTMLMetaElementImpl::~HTMLMetaElementImpl() 431 421 { 432 }433 434 NodeImpl::Id HTMLMetaElementImpl::id() const435 {436 return ID_META;437 422 } 438 423 … … 513 498 514 499 HTMLScriptElementImpl::HTMLScriptElementImpl(DocumentPtr *doc) 515 : HTMLElementImpl( doc), m_cachedScript(0), m_createdByParser(false), m_evaluated(false)500 : HTMLElementImpl(HTMLNames::script(), doc), m_cachedScript(0), m_createdByParser(false), m_evaluated(false) 516 501 { 517 502 } … … 521 506 if (m_cachedScript) 522 507 m_cachedScript->deref(this); 523 }524 525 NodeImpl::Id HTMLScriptElementImpl::id() const526 {527 return ID_SCRIPT;528 508 } 529 509 … … 698 678 // ------------------------------------------------------------------------- 699 679 700 HTMLStyleElementImpl::HTMLStyleElementImpl(DocumentPtr *doc) : HTMLElementImpl( doc)680 HTMLStyleElementImpl::HTMLStyleElementImpl(DocumentPtr *doc) : HTMLElementImpl(HTMLNames::style(), doc) 701 681 { 702 682 m_sheet = 0; … … 707 687 { 708 688 if(m_sheet) m_sheet->deref(); 709 }710 711 NodeImpl::Id HTMLStyleElementImpl::id() const712 {713 return ID_STYLE;714 689 } 715 690 … … 825 800 826 801 HTMLTitleElementImpl::HTMLTitleElementImpl(DocumentPtr *doc) 827 : HTMLElementImpl( doc), m_title("")802 : HTMLElementImpl(HTMLNames::title(), doc), m_title("") 828 803 { 829 804 } … … 831 806 HTMLTitleElementImpl::~HTMLTitleElementImpl() 832 807 { 833 }834 835 NodeImpl::Id HTMLTitleElementImpl::id() const836 {837 return ID_TITLE;838 808 } 839 809 -
trunk/WebCore/khtml/html/html_headimpl.h
r9431 r9639 50 50 ~HTMLBaseElementImpl(); 51 51 52 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 53 virtual int tagPriority() const { return 0; } 54 52 55 DOMString href() const { return m_href; } 53 56 DOMString target() const { return m_target; } 54 57 55 virtual Id id() const;56 58 virtual void parseMappedAttribute(MappedAttributeImpl *attr); 57 59 virtual void insertedIntoDocument(); … … 78 80 ~HTMLLinkElementImpl(); 79 81 80 virtual Id id() const; 82 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 83 virtual int tagPriority() const { return 0; } 81 84 82 85 bool disabled() const; … … 153 156 public: 154 157 HTMLMetaElementImpl(DocumentPtr *doc); 155 156 158 ~HTMLMetaElementImpl(); 157 159 158 virtual Id id() const; 160 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 161 virtual int tagPriority() const { return 0; } 162 159 163 virtual void parseMappedAttribute(MappedAttributeImpl *attr); 160 164 virtual void insertedIntoDocument(); … … 186 190 HTMLScriptElementImpl(DocumentPtr *doc); 187 191 ~HTMLScriptElementImpl(); 188 192 193 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 194 virtual int tagPriority() const { return 1; } 195 virtual bool checkDTD(const NodeImpl* newChild) { return newChild->isTextNode(); } 196 189 197 virtual void insertedIntoDocument(); 190 198 virtual void removedFromDocument(); 191 199 virtual void notifyFinished(khtml::CachedObject *finishedObj); 200 192 201 virtual void childrenChanged(); 193 194 virtual Id id() const; 202 195 203 virtual bool isURLAttribute(AttributeImpl *attr) const; 196 204 … … 234 242 ~HTMLStyleElementImpl(); 235 243 236 virtual Id id() const; 244 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 245 virtual int tagPriority() const { return 1; } 246 virtual bool checkDTD(const NodeImpl* newChild) { return newChild->isTextNode(); } 237 247 238 248 StyleSheetImpl *sheet() const { return m_sheet; } … … 269 279 public: 270 280 HTMLTitleElementImpl(DocumentPtr *doc); 271 272 281 ~HTMLTitleElementImpl(); 273 282 274 virtual Id id() const;283 virtual bool checkDTD(const NodeImpl* newChild) { return newChild->isTextNode(); } 275 284 276 285 virtual void insertedIntoDocument(); -
trunk/WebCore/khtml/html/html_imageimpl.cpp
r9450 r9639 52 52 using namespace khtml; 53 53 54 // #define INSTRUMENT_LAYOUT_SCHEDULING 154 // #define INSTRUMENT_LAYOUT_SCHEDULING 1 55 55 56 56 HTMLImageLoader::HTMLImageLoader(ElementImpl* elt) … … 76 76 77 77 AtomicString attr; 78 if (element()-> id() == ID_OBJECT)78 if (element()->hasLocalName(HTMLNames::object())) 79 79 attr = element()->getAttribute(ATTR_DATA); 80 80 else … … 87 87 88 88 if (newImage != m_image) { 89 #ifdef INSTRUMENT_LAYOUT_SCHEDULING 90 if (!document->ownerElement() && newImage) 91 printf("Image requested at %d\n", element()->getDocument()->elapsedTime()); 92 #endif 89 93 m_firedLoad = false; 90 94 m_imageComplete = false; … … 134 138 135 139 HTMLImageElementImpl::HTMLImageElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f) 136 : HTMLElementImpl( doc), m_imageLoader(this), ismap(false), m_form(f)140 : HTMLElementImpl(HTMLNames::img(), doc), m_imageLoader(this), ismap(false), m_form(f) 137 141 { 138 142 if (m_form) … … 140 144 } 141 145 146 HTMLImageElementImpl::HTMLImageElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 147 : HTMLElementImpl(tagName, doc), m_imageLoader(this), ismap(false), m_form(0) 148 { 149 } 150 142 151 HTMLImageElementImpl::~HTMLImageElementImpl() 143 152 { 144 153 if (m_form) 145 154 m_form->removeImgElement(this); 146 }147 148 NodeImpl::Id HTMLImageElementImpl::id() const149 {150 return ID_IMG;151 155 } 152 156 … … 529 533 530 534 HTMLMapElementImpl::HTMLMapElementImpl(DocumentPtr *doc) 531 : HTMLElementImpl( doc)535 : HTMLElementImpl(HTMLNames::map(), doc) 532 536 { 533 537 } … … 539 543 } 540 544 541 NodeImpl::Id HTMLMapElementImpl::id() const 542 { 543 return ID_MAP; 545 bool HTMLMapElementImpl::checkDTD(const NodeImpl* newChild) 546 { 547 // FIXME: This seems really odd, allowing only blocks inside map. 548 return newChild->hasTagName(HTMLNames::area()) || newChild->hasTagName(HTMLNames::script()) || 549 inBlockTagList(newChild); 544 550 } 545 551 … … 553 559 554 560 NodeImpl *current = firstChild(); 555 while(1) 556 { 557 if(!current) 558 { 561 while (1) { 562 if (!current) { 559 563 if(nodeStack.isEmpty()) break; 560 564 current = nodeStack.pop(); … … 562 566 continue; 563 567 } 564 if(current->id()==ID_AREA)565 {568 569 if (current->hasTagName(HTMLNames::area())) { 566 570 //cout << "area found " << endl; 567 HTMLAreaElementImpl* area =static_cast<HTMLAreaElementImpl*>(current);571 HTMLAreaElementImpl* area = static_cast<HTMLAreaElementImpl*>(current); 568 572 if (area->mapMouseEvent(x_,y_,width_,height_, info)) 569 573 return true; 570 574 } 575 571 576 NodeImpl *child = current->firstChild(); 572 if(child) 573 { 577 if (child) { 574 578 nodeStack.push(current); 575 579 current = child; 576 580 } 577 581 else 578 {579 582 current = current->nextSibling(); 580 }581 583 } 582 584 … … 623 625 624 626 HTMLAreaElementImpl::HTMLAreaElementImpl(DocumentPtr *doc) 625 : HTMLAnchorElementImpl( doc)627 : HTMLAnchorElementImpl(HTMLNames::area(), doc) 626 628 { 627 629 m_coords=0; … … 634 636 { 635 637 if (m_coords) delete [] m_coords; 636 }637 638 NodeImpl::Id HTMLAreaElementImpl::id() const639 {640 return ID_AREA;641 638 } 642 639 -
trunk/WebCore/khtml/html/html_imageimpl.h
r9158 r9639 76 76 public: 77 77 HTMLImageElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f = 0); 78 HTMLImageElementImpl(const QualifiedName& tagName, DocumentPtr* doc); 78 79 ~HTMLImageElementImpl(); 79 80 80 virtual Id id() const; 81 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 82 virtual int tagPriority() const { return 0; } 81 83 82 84 virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const; … … 162 164 ~HTMLAreaElementImpl(); 163 165 164 virtual Id id() const; 166 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 167 virtual int tagPriority() const { return 0; } 165 168 166 169 virtual void parseMappedAttribute(MappedAttributeImpl *attr); … … 213 216 public: 214 217 HTMLMapElementImpl(DocumentPtr *doc); 215 216 218 ~HTMLMapElementImpl(); 217 219 218 virtual Id id() const; 220 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 221 virtual int tagPriority() const { return 1; } 222 virtual bool checkDTD(const NodeImpl* newChild); 219 223 220 224 virtual DOMString getName() const { return m_name; } -
trunk/WebCore/khtml/html/html_inlineimpl.cpp
r9158 r9639 46 46 47 47 HTMLAnchorElementImpl::HTMLAnchorElementImpl(DocumentPtr *doc) 48 : HTMLElementImpl(doc) 48 : HTMLElementImpl(HTMLNames::a(), doc) 49 { 50 m_hasTarget = false; 51 } 52 53 HTMLAnchorElementImpl::HTMLAnchorElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 54 : HTMLElementImpl(tagName, doc) 49 55 { 50 56 m_hasTarget = false; … … 103 109 104 110 return getDocument()->part()->tabsToLinks(); 105 }106 107 NodeImpl::Id HTMLAnchorElementImpl::id() const108 {109 return ID_A;110 111 } 111 112 … … 153 154 utarget = "_blank"; 154 155 155 if ( evt->target()->id() == ID_IMG) {156 if (evt->target()->hasTagName(HTMLNames::img())) { 156 157 HTMLImageElementImpl* img = static_cast<HTMLImageElementImpl*>( evt->target() ); 157 158 if ( img && img->isServerMap() ) … … 383 384 // ------------------------------------------------------------------------- 384 385 385 HTMLBRElementImpl::HTMLBRElementImpl(DocumentPtr *doc) : HTMLElementImpl( doc)386 HTMLBRElementImpl::HTMLBRElementImpl(DocumentPtr *doc) : HTMLElementImpl(HTMLNames::br(), doc) 386 387 { 387 388 } … … 389 390 HTMLBRElementImpl::~HTMLBRElementImpl() 390 391 { 391 }392 393 NodeImpl::Id HTMLBRElementImpl::id() const394 {395 return ID_BR;396 392 } 397 393 … … 446 442 447 443 HTMLFontElementImpl::HTMLFontElementImpl(DocumentPtr *doc) 448 : HTMLElementImpl( doc)444 : HTMLElementImpl(HTMLNames::font(), doc) 449 445 { 450 446 } … … 452 448 HTMLFontElementImpl::~HTMLFontElementImpl() 453 449 { 454 }455 456 NodeImpl::Id HTMLFontElementImpl::id() const457 {458 return ID_FONT;459 450 } 460 451 … … 591 582 // ------------------------------------------------------------------------- 592 583 593 HTMLModElementImpl::HTMLModElementImpl( DocumentPtr *doc, ushort elementId)594 : HTML GenericElementImpl(doc, elementId)584 HTMLModElementImpl::HTMLModElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 585 : HTMLElementImpl(tagName, doc) 595 586 { 596 587 } … … 619 610 620 611 HTMLQuoteElementImpl::HTMLQuoteElementImpl(DocumentPtr *doc) 621 : HTMLElementImpl(doc) 622 { 623 } 624 625 NodeImpl::Id HTMLQuoteElementImpl::id() const 626 { 627 return ID_Q; 628 } 629 612 : HTMLElementImpl(HTMLNames::q(), doc) 613 { 614 } 615 630 616 DOMString HTMLQuoteElementImpl::cite() const 631 617 { -
trunk/WebCore/khtml/html/html_inlineimpl.h
r9158 r9639 35 35 public: 36 36 HTMLAnchorElementImpl(DocumentPtr *doc); 37 HTMLAnchorElementImpl(const QualifiedName& tagName, DocumentPtr* doc); 37 38 ~HTMLAnchorElementImpl(); 39 40 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 41 virtual int tagPriority() const { return 1; } 38 42 39 43 virtual bool isMouseFocusable() const; 40 44 virtual bool isKeyboardFocusable() const; 41 45 virtual bool isFocusable() const; 42 virtual Id id() const;43 46 virtual void parseMappedAttribute(MappedAttributeImpl *attr); 44 47 virtual void defaultEventHandler(EventImpl *evt); … … 98 101 HTMLBRElementImpl(DocumentPtr *doc); 99 102 ~HTMLBRElementImpl(); 103 104 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 105 virtual int tagPriority() const { return 0; } 100 106 101 virtual Id id() const;102 103 107 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; 104 108 virtual void parseMappedAttribute(MappedAttributeImpl *attr); … … 117 121 HTMLFontElementImpl(DocumentPtr *doc); 118 122 ~HTMLFontElementImpl(); 123 124 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 125 virtual int tagPriority() const { return 1; } 119 126 120 virtual Id id() const;121 122 127 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; 123 128 virtual void parseMappedAttribute(MappedAttributeImpl *attr); … … 135 140 // ------------------------------------------------------------------------- 136 141 137 class HTMLModElementImpl : public HTML GenericElementImpl142 class HTMLModElementImpl : public HTMLElementImpl 138 143 { 139 144 public: 140 HTMLModElementImpl(DocumentPtr *doc, ushort elementId); 145 HTMLModElementImpl(const QualifiedName& tagName, DocumentPtr *doc); 146 147 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 148 virtual int tagPriority() const { return 1; } 141 149 142 150 DOMString cite() const; … … 153 161 public: 154 162 HTMLQuoteElementImpl(DocumentPtr *doc); 163 164 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 165 virtual int tagPriority() const { return 1; } 155 166 156 virtual Id id() const;157 158 167 DOMString cite() const; 159 168 void setCite(const DOMString &); -
trunk/WebCore/khtml/html/html_listimpl.cpp
r9158 r9639 32 32 33 33 namespace DOM { 34 35 NodeImpl::Id HTMLUListElementImpl::id() const36 {37 return ID_UL;38 }39 34 40 35 bool HTMLUListElementImpl::mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const … … 85 80 // ------------------------------------------------------------------------- 86 81 87 NodeImpl::Id HTMLDirectoryElementImpl::id() const88 {89 return ID_DIR;90 }91 92 82 bool HTMLDirectoryElementImpl::compact() const 93 83 { … … 102 92 // ------------------------------------------------------------------------- 103 93 104 NodeImpl::Id HTMLMenuElementImpl::id() const105 {106 return ID_MENU;107 }108 109 94 bool HTMLMenuElementImpl::compact() const 110 95 { … … 118 103 119 104 // ------------------------------------------------------------------------- 120 121 NodeImpl::Id HTMLOListElementImpl::id() const122 {123 return ID_OL;124 }125 105 126 106 bool HTMLOListElementImpl::mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const … … 154 134 break; 155 135 case ATTR_START: 156 _start = !attr->isNull() ? attr->value().toInt() : 1; 136 _start = !attr->isNull() ? attr->value().toInt() : 1; 137 break; 157 138 default: 158 HTML UListElementImpl::parseMappedAttribute(attr);139 HTMLElementImpl::parseMappedAttribute(attr); 159 140 } 160 141 } … … 186 167 187 168 // ------------------------------------------------------------------------- 188 189 NodeImpl::Id HTMLLIElementImpl::id() const190 {191 return ID_LI;192 }193 169 194 170 bool HTMLLIElementImpl::mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const … … 253 229 NodeImpl *n = this; 254 230 while (!listNode && (n = n->parentNode())) { 255 switch (n->id()) { 256 case ID_UL: 257 case ID_OL: 258 listNode = n; 259 } 231 if (n->hasTagName(HTMLNames::ul()) || n->hasTagName(HTMLNames::ol())) 232 listNode = n; 260 233 } 261 234 … … 266 239 267 240 // If we are first, and the OL has a start attr, set the value. 268 if (listNode && listNode-> id() == ID_OL&& !m_render->previousSibling()) {241 if (listNode && listNode->hasTagName(HTMLNames::ol()) && !m_render->previousSibling()) { 269 242 HTMLOListElementImpl *ol = static_cast<HTMLOListElementImpl *>(listNode); 270 243 render->setValue(ol->start()); … … 296 269 setAttribute(ATTR_VALUE, QString::number(value)); 297 270 } 298 // ------------------------------------------------------------------------- 299 300 NodeImpl::Id HTMLDListElementImpl::id() const 301 { 302 return ID_DL; 303 } 271 272 // ------------------------------------------------------------------------- 304 273 305 274 bool HTMLDListElementImpl::compact() const -
trunk/WebCore/khtml/html/html_listimpl.h
r9158 r9639 36 36 { 37 37 public: 38 HTMLUListElementImpl(DocumentPtr *doc) : HTMLElementImpl( doc) {}38 HTMLUListElementImpl(DocumentPtr *doc) : HTMLElementImpl(HTMLNames::ul(), doc) {} 39 39 virtual ~HTMLUListElementImpl() {} 40 40 41 virtual Id id() const; 41 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 42 virtual int tagPriority() const { return 5; } 42 43 43 44 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; … … 58 59 { 59 60 public: 60 HTMLDirectoryElementImpl(DocumentPtr *doc) : HTMLElementImpl( doc) {}61 HTMLDirectoryElementImpl(DocumentPtr *doc) : HTMLElementImpl(HTMLNames::dir(), doc) {} 61 62 62 virtual Id id() const; 63 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 64 virtual int tagPriority() const { return 5; } 63 65 64 66 bool compact() const; … … 71 73 { 72 74 public: 73 HTMLMenuElementImpl(DocumentPtr *doc) : HTMLElementImpl( doc) {}75 HTMLMenuElementImpl(DocumentPtr *doc) : HTMLElementImpl(HTMLNames::menu(), doc) {} 74 76 75 virtual Id id() const; 77 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 78 virtual int tagPriority() const { return 5; } 76 79 77 80 bool compact() const; … … 81 84 // ------------------------------------------------------------------------- 82 85 83 class HTMLOListElementImpl : public HTML UListElementImpl86 class HTMLOListElementImpl : public HTMLElementImpl 84 87 { 85 88 public: 86 89 HTMLOListElementImpl(DocumentPtr *doc) 87 : HTMLUListElementImpl(doc) { _start = 1; } 90 : HTMLElementImpl(HTMLNames::ol(), doc) { _start = 1; } 91 92 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 93 virtual int tagPriority() const { return 5; } 88 94 89 virtual Id id() const;90 91 95 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; 92 96 virtual void parseMappedAttribute(MappedAttributeImpl *); … … 111 115 public: 112 116 HTMLLIElementImpl(DocumentPtr *doc) 113 : HTMLElementImpl( doc) { isValued = false; }117 : HTMLElementImpl(HTMLNames::li(), doc) { isValued = false; } 114 118 virtual ~HTMLLIElementImpl() {} 115 119 116 virtual Id id() const; 120 virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; } 121 virtual int tagPriority() const { return 3; } 117 122 118 123 virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const; … … 137 142 { 138 143 public: 139 HTMLDListElementImpl(DocumentPtr *doc) : HTMLElementImpl( doc) {}144 HTMLDListElementImpl(DocumentPtr *doc) : HTMLElementImpl(HTMLNames::dl(), doc) {} 140 145 virtual ~HTMLDListElementImpl() {} 141 146 142 virtual Id id() const; 147 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 148 virtual int tagPriority() const { return 5; } 143 149 144 150 bool compact() const; -
trunk/WebCore/khtml/html/html_miscimpl.cpp
r9360 r9639 36 36 37 37 HTMLBaseFontElementImpl::HTMLBaseFontElementImpl(DocumentPtr *doc) 38 : HTMLElementImpl(doc) 39 { 40 } 41 42 NodeImpl::Id HTMLBaseFontElementImpl::id() const 43 { 44 return ID_BASEFONT; 38 : HTMLElementImpl(HTMLNames::basefont(), doc) 39 { 45 40 } 46 41 … … 142 137 switch(type) { 143 138 case DOC_IMAGES: 144 if (e->id() == ID_IMG)139 if (e->hasLocalName(HTMLNames::img())) 145 140 found = true; 146 141 break; 147 142 case DOC_FORMS: 148 if(e-> id() == ID_FORM)143 if(e->hasLocalName(HTMLNames::form())) 149 144 found = true; 150 145 break; 151 146 case DOC_NAMEABLE_ITEMS: 152 if (e->id() == ID_IMG)153 found = true; 154 if (e->id() == ID_FORM)155 found = true; 156 if (e->id() == ID_APPLET)157 found = true; 158 if (e->id() == ID_EMBED)159 found = true; 160 if (e->id() == ID_OBJECT)147 if (e->hasLocalName(HTMLNames::img())) 148 found = true; 149 if (e->hasLocalName(HTMLNames::form())) 150 found = true; 151 if (e->hasLocalName(HTMLNames::applet())) 152 found = true; 153 if (e->hasLocalName(HTMLNames::embed())) 154 found = true; 155 if (e->hasLocalName(HTMLNames::object())) 161 156 found = true; 162 157 break; 163 158 case TABLE_TBODIES: 164 if (e->id() == ID_TBODY)165 found = true; 166 else if (e->id() == ID_TABLE)159 if (e->hasLocalName(HTMLNames::tbody())) 160 found = true; 161 else if (e->hasLocalName(HTMLNames::table())) 167 162 deep = false; 168 163 break; 169 164 case TR_CELLS: 170 if (e->id() == ID_TD || e->id() == ID_TH)171 found = true; 172 else if (e->id() == ID_TABLE)165 if (e->hasLocalName(HTMLNames::td()) || e->hasLocalName(HTMLNames::th())) 166 found = true; 167 else if (e->hasLocalName(HTMLNames::table())) 173 168 deep = false; 174 169 break; 175 170 case TABLE_ROWS: 176 171 case TSECTION_ROWS: 177 if (e->id() == ID_TR)178 found = true; 179 else if (e->id() == ID_TABLE)172 if (e->hasLocalName(HTMLNames::tr())) 173 found = true; 174 else if (e->hasLocalName(HTMLNames::table())) 180 175 deep = false; 181 176 break; 182 177 case SELECT_OPTIONS: 183 if (e->id() == ID_OPTION)178 if (e->hasLocalName(HTMLNames::option())) 184 179 found = true; 185 180 break; 186 181 case MAP_AREAS: 187 if (e->id() == ID_AREA)182 if (e->hasLocalName(HTMLNames::area())) 188 183 found = true; 189 184 break; 190 185 case DOC_APPLETS: // all OBJECT and APPLET elements 191 if (e->id() == ID_OBJECT || e->id() == ID_APPLET)186 if (e->hasLocalName(HTMLNames::object()) || e->hasLocalName(HTMLNames::applet())) 192 187 found = true; 193 188 break; 194 189 case DOC_EMBEDS: // all EMBED elements 195 if (e->id() == ID_EMBED)190 if (e->hasLocalName(HTMLNames::embed())) 196 191 found = true; 197 192 break; 198 193 case DOC_OBJECTS: // all OBJECT elements 199 if (e->id() == ID_OBJECT)194 if (e->hasLocalName(HTMLNames::object())) 200 195 found = true; 201 196 break; 202 197 case DOC_LINKS: // all A _and_ AREA elements with a value for href 203 if (e->id() == ID_A || e->id() == ID_AREA)204 if (!e->getAttribute(ATTR_HREF).isNull())198 if (e->hasLocalName(HTMLNames::a()) || e->hasLocalName(HTMLNames::area())) 199 if (!e->getAttribute(ATTR_HREF).isNull()) 205 200 found = true; 206 201 break; 207 202 case DOC_ANCHORS: // all A elements with a value for name or an id attribute 208 if (e->id() == ID_A)209 if (!e->getAttribute(ATTR_NAME).isNull())203 if (e->hasLocalName(HTMLNames::a())) 204 if (!e->getAttribute(ATTR_NAME).isNull()) 210 205 found = true; 211 206 break; … … 220 215 kdDebug( 6030 ) << "Error in HTMLCollection, wrong tagId!" << endl; 221 216 } 222 if (found) { 217 218 if (found) 223 219 return current; 224 }225 220 if (deep) { 226 221 current = current->traverseNextNode(m_base.get()); … … 299 294 bool HTMLCollectionImpl::checkForNameMatch(NodeImpl *node, bool checkName, const DOMString &name, bool caseSensitive) const 300 295 { 301 ElementImpl *e = static_cast<ElementImpl *>(node); 296 if (!node->isHTMLElement()) 297 return false; 298 299 HTMLElementImpl *e = static_cast<HTMLElementImpl*>(node); 302 300 if (caseSensitive) { 303 301 if (checkName) { … … 305 303 // by name (though everything by id) 306 304 if (type == DOC_ALL && 307 !(e-> id() == ID_IMG || e->id() == ID_FORM||308 e-> id() == ID_APPLET || e->id() == ID_OBJECT||309 e-> id() == ID_EMBED))305 !(e->hasLocalName(HTMLNames::img()) || e->hasLocalName(HTMLNames::form()) || 306 e->hasLocalName(HTMLNames::applet()) || e->hasLocalName(HTMLNames::object()) || 307 e->hasLocalName(HTMLNames::embed()))) 310 308 return false; 311 309 312 310 return e->getAttribute(ATTR_NAME) == name && e->getAttribute(ATTR_ID) != name; 313 } else {311 } else 314 312 return e->getAttribute(ATTR_ID) == name; 315 }316 313 } else { 317 314 if (checkName) { … … 319 316 // by name (though everything by id) 320 317 if (type == DOC_ALL && 321 !(e-> id() == ID_IMG || e->id() == ID_FORM||322 e-> id() == ID_APPLET || e->id() == ID_OBJECT||323 e-> id() == ID_EMBED))318 !(e->hasLocalName(HTMLNames::img()) || e->hasLocalName(HTMLNames::form()) || 319 e->hasLocalName(HTMLNames::applet()) || e->hasLocalName(HTMLNames::object()) || 320 e->hasLocalName(HTMLNames::embed()))) 324 321 return false; 325 322 … … 380 377 381 378 for (NodeImpl *n = traverseNextItem(m_base.get()); n; n = traverseNextItem(n)) { 382 ElementImpl *e = static_cast<ElementImpl *>(n); 379 if (!n->isHTMLElement()) 380 continue; 381 HTMLElementImpl* e = static_cast<HTMLElementImpl*>(n); 383 382 QString idAttr = e->getAttribute(ATTR_ID).string(); 384 383 QString nameAttr = e->getAttribute(ATTR_NAME).string(); … … 394 393 if (!nameAttr.isEmpty() && idAttr != nameAttr 395 394 && (type != DOC_ALL || 396 (e-> id() == ID_IMG || e->id() == ID_FORM||397 e-> id() == ID_APPLET || e->id() == ID_OBJECT||398 e-> id() == ID_EMBED))) {395 (e->hasLocalName(HTMLNames::img()) || e->hasLocalName(HTMLNames::form()) || 396 e->hasLocalName(HTMLNames::applet()) || e->hasLocalName(HTMLNames::object()) || 397 e->hasLocalName(HTMLNames::embed())))) { 399 398 // add to name cache 400 399 QPtrVector<NodeImpl> *nameVector = info->nameCache.find(nameAttr); … … 533 532 NodeImpl* HTMLFormCollectionImpl::getNamedFormItem(int attr_id, const DOMString& name, int duplicateNumber, bool caseSensitive) const 534 533 { 535 if(m_base->nodeType() == Node::ELEMENT_NODE) 536 { 534 if (m_base->nodeType() == Node::ELEMENT_NODE) { 537 535 HTMLElementImpl* baseElement = static_cast<HTMLElementImpl*>(m_base.get()); 538 536 bool foundInputElements = false; 539 if(baseElement->id() == ID_FORM) 540 { 537 if (baseElement->hasLocalName(HTMLNames::form())) { 541 538 HTMLFormElementImpl* f = static_cast<HTMLFormElementImpl*>(baseElement); 542 539 for (unsigned i = 0; i < f->formElements.count(); ++i) { … … 558 555 } 559 556 560 if ( !foundInputElements ) 561 { 557 if (!foundInputElements) { 562 558 HTMLFormElementImpl* f = static_cast<HTMLFormElementImpl*>(baseElement); 563 559 … … 651 647 QDict<char> foundInputElements; 652 648 653 if ( m_base->id() != ID_FORM) {649 if (!m_base->hasTagName(HTMLNames::form())) { 654 650 info->hasNameCache = true; 655 651 return; -
trunk/WebCore/khtml/html/html_miscimpl.h
r9156 r9639 40 40 HTMLBaseFontElementImpl(DocumentPtr *doc); 41 41 42 virtual Id id() const; 42 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 43 virtual int tagPriority() const { return 0; } 43 44 44 45 DOMString color() const; -
trunk/WebCore/khtml/html/html_objectimpl.cpp
r9521 r9639 59 59 60 60 HTMLAppletElementImpl::HTMLAppletElementImpl(DocumentPtr *doc) 61 : HTMLElementImpl( doc)61 : HTMLElementImpl(HTMLNames::applet(), doc) 62 62 { 63 63 appletInstance = 0; … … 70 70 } 71 71 72 NodeImpl::Id HTMLAppletElementImpl::id() const 73 { 74 return ID_APPLET;72 bool HTMLAppletElementImpl::checkDTD(const NodeImpl* newChild) 73 { 74 return newChild->hasTagName(HTMLNames::param()) || HTMLElementImpl::checkDTD(newChild); 75 75 } 76 76 … … 354 354 355 355 HTMLEmbedElementImpl::HTMLEmbedElementImpl(DocumentPtr *doc) 356 : HTMLElementImpl( doc), embedInstance(0)356 : HTMLElementImpl(HTMLNames::embed(), doc), embedInstance(0) 357 357 {} 358 358 … … 361 361 } 362 362 363 NodeImpl::Id HTMLEmbedElementImpl::id() const 364 { 365 return ID_EMBED;363 bool HTMLEmbedElementImpl::checkDTD(const NodeImpl* newChild) 364 { 365 return newChild->hasTagName(HTMLNames::param()) || HTMLElementImpl::checkDTD(newChild); 366 366 } 367 367 … … 480 480 if (!part) 481 481 return false; 482 return part->pluginsEnabled() && parentNode()->id() != ID_OBJECT;482 return part->pluginsEnabled() && !parentNode()->hasTagName(HTMLNames::object()); 483 483 } 484 484 … … 505 505 HTMLObjectElementImpl::HTMLObjectElementImpl(DocumentPtr *doc) 506 506 #if APPLE_CHANGES 507 : HTMLElementImpl( doc), m_imageLoader(0), objectInstance(0)507 : HTMLElementImpl(HTMLNames::object(), doc), m_imageLoader(0), objectInstance(0) 508 508 #else 509 : HTMLElementImpl( doc), m_imageLoader(0)509 : HTMLElementImpl(HTMLNames::object(), doc), m_imageLoader(0) 510 510 #endif 511 511 { … … 519 519 } 520 520 521 NodeImpl::Id HTMLObjectElementImpl::id() const 522 { 523 return ID_OBJECT;521 bool HTMLObjectElementImpl::checkDTD(const NodeImpl* newChild) 522 { 523 return newChild->hasTagName(HTMLNames::param()) || HTMLElementImpl::checkDTD(newChild); 524 524 } 525 525 … … 556 556 { 557 557 for (NodeImpl *p = parentNode(); p != 0; p = p->parentNode()) { 558 if (p-> id() == ID_FORM)558 if (p->hasTagName(HTMLNames::form())) 559 559 return static_cast<HTMLFormElementImpl *>(p); 560 560 } … … 951 951 952 952 HTMLParamElementImpl::HTMLParamElementImpl(DocumentPtr *doc) 953 : HTMLElementImpl( doc)953 : HTMLElementImpl(HTMLNames::param(), doc) 954 954 { 955 955 } … … 957 957 HTMLParamElementImpl::~HTMLParamElementImpl() 958 958 { 959 }960 961 NodeImpl::Id HTMLParamElementImpl::id() const962 {963 return ID_PARAM;964 959 } 965 960 -
trunk/WebCore/khtml/html/html_objectimpl.h
r9158 r9639 43 43 public: 44 44 HTMLAppletElementImpl(DocumentPtr *doc); 45 46 45 ~HTMLAppletElementImpl(); 47 46 48 virtual Id id() const; 49 47 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 48 virtual int tagPriority() const { return 1; } 49 virtual bool checkDTD(const NodeImpl* newChild); 50 50 51 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; 51 52 virtual void parseMappedAttribute(MappedAttributeImpl *token); … … 113 114 public: 114 115 HTMLEmbedElementImpl(DocumentPtr *doc); 115 116 116 ~HTMLEmbedElementImpl(); 117 117 118 virtual Id id() const; 118 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 119 virtual int tagPriority() const { return 0; } 120 virtual bool checkDTD(const NodeImpl* newChild); 119 121 120 122 virtual bool mapToEntry(Id attr, MappedAttributeEntry& result) const; … … 147 149 public: 148 150 HTMLObjectElementImpl(DocumentPtr *doc); 149 150 151 ~HTMLObjectElementImpl(); 151 152 152 virtual Id id() const; 153 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 154 virtual int tagPriority() const { return 7; } 155 virtual bool checkDTD(const NodeImpl* newChild); 153 156 154 157 HTMLFormElementImpl *form() const; … … 248 251 public: 249 252 HTMLParamElementImpl(DocumentPtr *doc); 250 251 253 ~HTMLParamElementImpl(); 252 254 253 virtual Id id() const; 255 virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; } 256 virtual int tagPriority() const { return 0; } 254 257 255 258 virtual void parseMappedAttribute(MappedAttributeImpl *token); -
trunk/WebCore/khtml/html/html_tableimpl.cpp
r9420 r9639 52 52 53 53 HTMLTableElementImpl::HTMLTableElementImpl(DocumentPtr *doc) 54 : HTMLElementImpl( doc)54 : HTMLElementImpl(HTMLNames::table(), doc) 55 55 { 56 56 tCaption = 0; … … 74 74 } 75 75 76 NodeImpl::Id HTMLTableElementImpl::id() const 77 { 78 return ID_TABLE; 76 bool HTMLTableElementImpl::checkDTD(const NodeImpl* newChild) 77 { 78 return newChild->isTextNode() || newChild->hasTagName(HTMLNames::caption()) || 79 newChild->hasTagName(HTMLNames::col()) || newChild->hasTagName(HTMLNames::colgroup()) || 80 newChild->hasTagName(HTMLNames::thead()) || newChild->hasTagName(HTMLNames::tfoot()) || 81 newChild->hasTagName(HTMLNames::tbody()) || newChild->hasTagName(HTMLNames::form()) || 82 newChild->hasTagName(HTMLNames::script()); 79 83 } 80 84 … … 147 151 { 148 152 int exceptioncode = 0; 149 head = new HTMLTableSectionElementImpl( docPtr(), ID_THEAD, true /* implicit */);153 head = new HTMLTableSectionElementImpl(HTMLNames::thead(), docPtr(), true /* implicit */); 150 154 if(foot) 151 155 insertBefore( head, foot, exceptioncode ); … … 172 176 { 173 177 int exceptioncode = 0; 174 foot = new HTMLTableSectionElementImpl( docPtr(), ID_TFOOT, true /*implicit */);178 foot = new HTMLTableSectionElementImpl(HTMLNames::tfoot(), docPtr(), true /*implicit */); 175 179 if(firstBody) 176 180 insertBefore( foot, firstBody, exceptioncode ); … … 217 221 // <TABLE><TR>) 218 222 if(!firstBody && !head && !foot && !hasChildNodes()) 219 setTBody( new HTMLTableSectionElementImpl( docPtr(), ID_TBODY, true /* implicit */) );223 setTBody( new HTMLTableSectionElementImpl(HTMLNames::tbody(), docPtr(), true /* implicit */) ); 220 224 221 225 //kdDebug(6030) << k_funcinfo << index << endl; … … 231 235 // there could be 2 tfoot elements in the table. Only the first one is the "foot", that's why we have the more 232 236 // complicated if statement below. 233 if ( node != foot && (node->id() == ID_THEAD || node->id() == ID_TFOOT || node->id() == ID_TBODY) ) 237 if (node != foot && (node->hasTagName(HTMLNames::thead()) || node->hasTagName(HTMLNames::tfoot()) || 238 node->hasTagName(HTMLNames::tbody()))) 234 239 { 235 240 section = static_cast<HTMLTableSectionElementImpl *>(node); … … 277 282 for ( ; node ; node = node->nextSibling() ) 278 283 { 279 if ( node != foot && (node->id() == ID_THEAD || node->id() == ID_TFOOT || node->id() == ID_TBODY) )280 {284 if (node != foot && (node->hasTagName(HTMLNames::thead()) || node->hasTagName(HTMLNames::tfoot()) || 285 node->hasTagName(HTMLNames::tbody()))) { 281 286 section = static_cast<HTMLTableSectionElementImpl *>(node); 282 287 lastSection = section; … … 310 315 #endif 311 316 312 if (child-> id() == ID_FORM) {317 if (child->hasTagName(HTMLNames::form())) { 313 318 // First add the child. 314 319 HTMLElementImpl::addChild(child); … … 338 343 int exceptioncode = 0; 339 344 NodeImpl *retval = appendChild( child, exceptioncode ); 340 if ( retval ) { 341 switch(child->id()) { 342 case ID_CAPTION: 343 if ( !tCaption ) 344 tCaption = static_cast<HTMLTableCaptionElementImpl *>(child); 345 break; 346 case ID_COL: 347 case ID_COLGROUP: 348 break; 349 case ID_THEAD: 350 if ( !head ) 351 head = static_cast<HTMLTableSectionElementImpl *>(child); 352 break; 353 case ID_TFOOT: 354 if ( !foot ) 355 foot = static_cast<HTMLTableSectionElementImpl *>(child); 356 break; 357 case ID_TBODY: 358 if ( !firstBody ) 359 firstBody = static_cast<HTMLTableSectionElementImpl *>(child); 360 break; 361 } 345 if (retval) { 346 if (!tCaption && child->hasTagName(HTMLNames::caption())) 347 tCaption = static_cast<HTMLTableCaptionElementImpl *>(child); 348 else if (!head && child->hasTagName(HTMLNames::thead())) 349 head = static_cast<HTMLTableSectionElementImpl *>(child); 350 else if (!foot && child->hasTagName(HTMLNames::tfoot())) 351 foot = static_cast<HTMLTableSectionElementImpl *>(child); 352 else if (!firstBody && child->hasTagName(HTMLNames::tbody())) 353 firstBody = static_cast<HTMLTableSectionElementImpl *>(child); 362 354 } 363 355 return retval; … … 803 795 // ------------------------------------------------------------------------- 804 796 805 HTMLTableSectionElementImpl::HTMLTableSectionElementImpl(DocumentPtr *doc, 806 ushort tagid, bool implicit) 807 : HTMLTablePartElementImpl(doc) 808 { 809 _id = tagid; 797 HTMLTableSectionElementImpl::HTMLTableSectionElementImpl(const QualifiedName& tagName, DocumentPtr *doc, bool implicit) 798 : HTMLTablePartElementImpl(tagName, doc) 799 { 810 800 m_implicit = implicit; 811 801 } 812 802 813 NodeImpl::Id HTMLTableSectionElementImpl::id() const 814 { 815 return _id; 803 bool HTMLTableSectionElementImpl::checkDTD(const NodeImpl* newChild) 804 { 805 return newChild->hasTagName(HTMLNames::tr()) || newChild->hasTagName(HTMLNames::form()) || 806 newChild->hasTagName(HTMLNames::script()); 816 807 } 817 808 … … 822 813 #endif 823 814 824 if (child-> id() == ID_FORM) {815 if (child->hasTagName(HTMLNames::form())) { 825 816 // First add the child. 826 817 HTMLElementImpl::addChild(child); … … 878 869 const NodeImpl *n = firstChild(); 879 870 while (n) { 880 if (n-> id() == ID_TR)871 if (n->hasTagName(HTMLNames::tr())) 881 872 rows++; 882 873 n = n->nextSibling(); … … 933 924 // ------------------------------------------------------------------------- 934 925 935 NodeImpl::Id HTMLTableRowElementImpl::id() const 936 { 937 return ID_TR; 926 bool HTMLTableRowElementImpl::checkDTD(const NodeImpl* newChild) 927 { 928 return newChild->hasTagName(HTMLNames::td()) || newChild->hasTagName(HTMLNames::th()) || 929 newChild->hasTagName(HTMLNames::form()) || newChild->hasTagName(HTMLNames::script()); 938 930 } 939 931 … … 944 936 #endif 945 937 946 if (child-> id() == ID_FORM) {938 if (child->hasTagName(HTMLNames::form())) { 947 939 // First add the child. 948 940 HTMLElementImpl::addChild(child); … … 959 951 960 952 NodeImpl *table = parentNode(); 961 if ( !table)953 if (!table) 962 954 return -1; 963 955 table = table->parentNode(); 964 if ( !table || table->id() != ID_TABLE)956 if (!table || !table->hasTagName(HTMLNames::table())) 965 957 return -1; 966 958 967 959 HTMLTableSectionElementImpl *foot = static_cast<HTMLTableElementImpl *>(table)->tFoot(); 968 960 NodeImpl *node = table->firstChild(); 969 while ( node) {970 if ( node != foot && (node->id() == ID_THEAD || node->id() == ID_TFOOT || node->id() == ID_TBODY)) {961 while (node) { 962 if (node != foot && (node->hasTagName(HTMLNames::thead()) || node->hasTagName(HTMLNames::tfoot()) || node->hasTagName(HTMLNames::tbody()))) { 971 963 HTMLTableSectionElementImpl* section = static_cast<HTMLTableSectionElementImpl *>(node); 972 964 const NodeImpl *row = section->firstChild(); … … 997 989 do { 998 990 n = n->previousSibling(); 999 if (n && n-> isElementNode() && n->id() == ID_TR)991 if (n && n->hasTagName(HTMLNames::tr())) 1000 992 rIndex++; 1001 993 } … … 1014 1006 else 1015 1007 { 1016 c = new HTMLTableCellElementImpl( docPtr(), ID_TD);1008 c = new HTMLTableCellElementImpl(HTMLNames::td(), docPtr()); 1017 1009 if(numCells == index || index == -1) 1018 1010 appendChild(c, exceptioncode); … … 1104 1096 // ------------------------------------------------------------------------- 1105 1097 1106 HTMLTableCellElementImpl::HTMLTableCellElementImpl(DocumentPtr *doc, int tag) 1107 : HTMLTablePartElementImpl(doc) 1108 { 1109 _col = -1; 1110 _row = -1; 1111 cSpan = rSpan = 1; 1112 _id = tag; 1113 rowHeight = 0; 1114 m_solid = false; 1098 HTMLTableCellElementImpl::HTMLTableCellElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 1099 : HTMLTablePartElementImpl(tagName, doc) 1100 { 1101 _col = -1; 1102 _row = -1; 1103 cSpan = rSpan = 1; 1104 rowHeight = 0; 1105 m_solid = false; 1115 1106 } 1116 1107 … … 1123 1114 int index = 0; 1124 1115 for (const NodeImpl * node = previousSibling(); node; node = node->previousSibling()) { 1125 if (node-> id() == ID_TD || node->id() == ID_TH)1116 if (node->hasTagName(HTMLNames::td()) || node->hasTagName(HTMLNames::th())) 1126 1117 index++; 1127 1118 } … … 1190 1181 CSSMutableStyleDeclarationImpl* HTMLTableCellElementImpl::additionalAttributeStyleDecl() 1191 1182 { 1192 HTMLElementImpl* p = static_cast<HTMLElementImpl*>(parentNode());1193 while (p && p->id() != ID_TABLE)1194 p = static_cast<HTMLElementImpl*>(p->parentNode());1183 NodeImpl* p = parentNode(); 1184 while (p && !p->hasTagName(HTMLNames::table())) 1185 p = p->parentNode(); 1195 1186 1196 1187 if (p) { … … 1202 1193 } 1203 1194 1204 void HTMLTableCellElementImpl::attach()1205 {1206 HTMLElementImpl* p = static_cast<HTMLElementImpl*>(parentNode());1207 while(p && p->id() != ID_TABLE)1208 p = static_cast<HTMLElementImpl*>(p->parentNode());1209 1210 HTMLTablePartElementImpl::attach();1211 }1212 1213 1195 bool HTMLTableCellElementImpl::isURLAttribute(AttributeImpl *attr) const 1214 1196 { … … 1348 1330 // ------------------------------------------------------------------------- 1349 1331 1350 HTMLTableColElementImpl::HTMLTableColElementImpl(DocumentPtr *doc, ushort i) 1351 : HTMLTablePartElementImpl(doc) 1352 { 1353 _id = i; 1354 _span = (_id == ID_COLGROUP ? 0 : 1); 1355 } 1356 1357 NodeImpl::Id HTMLTableColElementImpl::id() const 1358 { 1359 return _id; 1332 HTMLTableColElementImpl::HTMLTableColElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 1333 : HTMLTablePartElementImpl(tagName, doc) 1334 { 1335 _span = (tagName.matches(HTMLNames::colgroup()) ? 0 : 1); 1360 1336 } 1361 1337 … … 1448 1424 // ------------------------------------------------------------------------- 1449 1425 1450 NodeImpl::Id HTMLTableCaptionElementImpl::id() const1451 {1452 return ID_CAPTION;1453 }1454 1455 1426 bool HTMLTableCaptionElementImpl::mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const 1456 1427 { -
trunk/WebCore/khtml/html/html_tableimpl.h
r9420 r9639 63 63 ~HTMLTableElementImpl(); 64 64 65 virtual Id id() const; 65 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 66 virtual int tagPriority() const { return 9; } 67 virtual bool checkDTD(const NodeImpl* newChild); 66 68 67 69 HTMLTableCaptionElementImpl *caption() const { return tCaption; } … … 148 150 { 149 151 public: 150 HTMLTablePartElementImpl( DocumentPtr *doc)151 : HTMLElementImpl( doc)152 HTMLTablePartElementImpl(const QualifiedName& tagName, DocumentPtr *doc) 153 : HTMLElementImpl(tagName, doc) 152 154 { } 153 155 … … 161 163 { 162 164 public: 163 HTMLTableSectionElementImpl(DocumentPtr *doc, ushort tagid, bool implicit); 164 165 virtual Id id() const; 165 HTMLTableSectionElementImpl(const QualifiedName& tagName, DocumentPtr *doc, bool implicit); 166 167 virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; } 168 virtual int tagPriority() const { return 8; } 169 virtual bool checkDTD(const NodeImpl* newChild); 166 170 167 171 virtual NodeImpl *addChild(NodeImpl *child); … … 185 189 186 190 khtml::SharedPtr<HTMLCollectionImpl> rows(); 187 188 protected:189 ushort _id;190 191 }; 191 192 … … 196 197 public: 197 198 HTMLTableRowElementImpl(DocumentPtr *doc) 198 : HTMLTablePartElementImpl(doc) {} 199 200 virtual Id id() const; 201 199 : HTMLTablePartElementImpl(HTMLNames::tr(), doc) {} 200 201 virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; } 202 virtual int tagPriority() const { return 7; } 203 virtual bool checkDTD(const NodeImpl* newChild); 204 202 205 virtual NodeImpl *addChild(NodeImpl *child); 203 206 … … 239 242 { 240 243 public: 241 HTMLTableCellElementImpl( DocumentPtr *doc, int tagId);244 HTMLTableCellElementImpl(const QualifiedName& tagName, DocumentPtr *doc); 242 245 ~HTMLTableCellElementImpl(); 243 246 244 // ### FIX these two... 247 virtual HTMLTagStatus endTagRequirement() const { return TagStatusOptional; } 248 virtual int tagPriority() const { return 6; } 249 245 250 long cellIndex() const; 246 251 … … 252 257 int colSpan() const { return cSpan; } 253 258 int rowSpan() const { return rSpan; } 254 255 virtual Id id() const { return _id; } 256 257 virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const; 258 virtual void parseMappedAttribute(MappedAttributeImpl *attr); 259 260 virtual void attach(); 259 260 virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const; 261 virtual void parseMappedAttribute(MappedAttributeImpl *attr); 261 262 262 263 // used by table cells to share style decls created by the enclosing table. … … 312 313 int rSpan; 313 314 int cSpan; 314 int _id;315 315 int rowHeight; 316 316 bool m_solid : 1; … … 322 322 { 323 323 public: 324 HTMLTableColElementImpl(DocumentPtr *doc, ushort i); 325 326 virtual Id id() const; 327 324 HTMLTableColElementImpl(const QualifiedName& tagName, DocumentPtr *doc); 325 326 virtual HTMLTagStatus endTagRequirement() const { return hasLocalName(HTMLNames::col()) ? TagStatusForbidden : TagStatusOptional; } 327 virtual int tagPriority() const { return hasLocalName(HTMLNames::col()) ? 0 : 1; } 328 virtual bool checkDTD(const NodeImpl* newChild) { return hasLocalName(HTMLNames::colgroup()) && newChild->hasTagName(HTMLNames::col()); } 328 329 void setTable(HTMLTableElementImpl *t) { table = t; } 329 330 … … 352 353 353 354 protected: 354 // could be ID_COL or ID_COLGROUP ... The DOM is not quite clear on355 // this, but since both elements work quite similar, we use one356 // DOMElement for them...357 ushort _id;358 355 int _span; 359 356 HTMLTableElementImpl *table; … … 366 363 public: 367 364 HTMLTableCaptionElementImpl(DocumentPtr *doc) 368 : HTMLTablePartElementImpl(doc) {} 369 370 virtual Id id() const; 365 : HTMLTablePartElementImpl(HTMLNames::caption(), doc) {} 366 367 virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; } 368 virtual int tagPriority() const { return 5; } 371 369 372 370 virtual bool mapToEntry(NodeImpl::Id attr, MappedAttributeEntry& result) const; -
trunk/WebCore/khtml/html/htmlnames.cpp
r9402 r9639 21 21 */ 22 22 23 #define KHTML_HTMLNAMES_HIDE_GLOBALS 1 24 25 #include <qptrdict.h> 23 26 #include "htmlnames.h" 24 27 #include "dom_qname.h" … … 26 29 namespace DOM { 27 30 28 const AtomicString& HTMLNames::xhtmlNamespaceURI() 31 void* xhtmlNamespaceURIAtom[(sizeof(AtomicString) + sizeof(void*) - 1) / sizeof(void*)]; 32 33 // Define a QualifiedName-sized array of pointers to avoid static initialization. 34 // Use an array of pointers instead of an array of char in case there is some alignment issue. 35 #define DEFINE_GLOBAL(name) \ 36 void* name ## QName[(sizeof(QualifiedName) + sizeof(void*) - 1) / sizeof(void*)]; 37 38 DEFINE_GLOBAL(a) 39 DEFINE_GLOBAL(abbr) 40 DEFINE_GLOBAL(acronym) 41 DEFINE_GLOBAL(address) 42 DEFINE_GLOBAL(applet) 43 DEFINE_GLOBAL(area) 44 DEFINE_GLOBAL(b) 45 DEFINE_GLOBAL(base) 46 DEFINE_GLOBAL(basefont) 47 DEFINE_GLOBAL(bdo) 48 DEFINE_GLOBAL(big) 49 DEFINE_GLOBAL(blockquote) 50 DEFINE_GLOBAL(body) 51 DEFINE_GLOBAL(br) 52 DEFINE_GLOBAL(button) 53 DEFINE_GLOBAL(canvas) 54 DEFINE_GLOBAL(caption) 55 DEFINE_GLOBAL(center) 56 DEFINE_GLOBAL(cite) 57 DEFINE_GLOBAL(code) 58 DEFINE_GLOBAL(col) 59 DEFINE_GLOBAL(colgroup) 60 DEFINE_GLOBAL(dd) 61 DEFINE_GLOBAL(del) 62 DEFINE_GLOBAL(dfn) 63 DEFINE_GLOBAL(dir) 64 DEFINE_GLOBAL(div) 65 DEFINE_GLOBAL(dl) 66 DEFINE_GLOBAL(dt) 67 DEFINE_GLOBAL(em) 68 DEFINE_GLOBAL(embed) 69 DEFINE_GLOBAL(fieldset) 70 DEFINE_GLOBAL(font) 71 DEFINE_GLOBAL(form) 72 DEFINE_GLOBAL(frame) 73 DEFINE_GLOBAL(frameset) 74 DEFINE_GLOBAL(head) 75 DEFINE_GLOBAL(h1) 76 DEFINE_GLOBAL(h2) 77 DEFINE_GLOBAL(h3) 78 DEFINE_GLOBAL(h4) 79 DEFINE_GLOBAL(h5) 80 DEFINE_GLOBAL(h6) 81 DEFINE_GLOBAL(hr) 82 DEFINE_GLOBAL(html) 83 DEFINE_GLOBAL(i) 84 DEFINE_GLOBAL(iframe) 85 DEFINE_GLOBAL(img) 86 DEFINE_GLOBAL(input) 87 DEFINE_GLOBAL(ins) 88 DEFINE_GLOBAL(isindex) 89 DEFINE_GLOBAL(kbd) 90 DEFINE_GLOBAL(keygen) 91 DEFINE_GLOBAL(label) 92 DEFINE_GLOBAL(layer) 93 DEFINE_GLOBAL(legend) 94 DEFINE_GLOBAL(li) 95 DEFINE_GLOBAL(link) 96 DEFINE_GLOBAL(map) 97 DEFINE_GLOBAL(marquee) 98 DEFINE_GLOBAL(menu) 99 DEFINE_GLOBAL(meta) 100 DEFINE_GLOBAL(nobr) 101 DEFINE_GLOBAL(noembed) 102 DEFINE_GLOBAL(noframes) 103 DEFINE_GLOBAL(nolayer) 104 DEFINE_GLOBAL(noscript) 105 DEFINE_GLOBAL(object) 106 DEFINE_GLOBAL(ol) 107 DEFINE_GLOBAL(optgroup) 108 DEFINE_GLOBAL(option) 109 DEFINE_GLOBAL(p) 110 DEFINE_GLOBAL(param) 111 DEFINE_GLOBAL(plaintext) 112 DEFINE_GLOBAL(pre) 113 DEFINE_GLOBAL(q) 114 DEFINE_GLOBAL(s) 115 DEFINE_GLOBAL(samp) 116 DEFINE_GLOBAL(script) 117 DEFINE_GLOBAL(select) 118 DEFINE_GLOBAL(small) 119 DEFINE_GLOBAL(span) 120 DEFINE_GLOBAL(strike) 121 DEFINE_GLOBAL(strong) 122 DEFINE_GLOBAL(style) 123 DEFINE_GLOBAL(sub) 124 DEFINE_GLOBAL(sup) 125 DEFINE_GLOBAL(table) 126 DEFINE_GLOBAL(tbody) 127 DEFINE_GLOBAL(td) 128 DEFINE_GLOBAL(textarea) 129 DEFINE_GLOBAL(tfoot) 130 DEFINE_GLOBAL(th) 131 DEFINE_GLOBAL(thead) 132 DEFINE_GLOBAL(title) 133 DEFINE_GLOBAL(tr) 134 DEFINE_GLOBAL(tt) 135 DEFINE_GLOBAL(u) 136 DEFINE_GLOBAL(ul) 137 DEFINE_GLOBAL(var) 138 DEFINE_GLOBAL(wbr) 139 DEFINE_GLOBAL(xmp) 140 141 void HTMLNames::init() 29 142 { 30 static AtomicString xhtmlNS("http://www.w3.org/1999/xhtml"); 31 return xhtmlNS; 143 static bool initialized; 144 if (!initialized) { 145 // Use placement new to initialize the globals. 146 static AtomicString xhtmlNS("http://www.w3.org/1999/xhtml"); 147 new (&xhtmlNamespaceURIAtom) AtomicString(xhtmlNS); 148 new (&aQName) QualifiedName(nullAtom, "a", xhtmlNS); 149 new (&abbrQName) QualifiedName(nullAtom, "abbr", xhtmlNS); 150 new (&acronymQName) QualifiedName(nullAtom, "acronym", xhtmlNS); 151 new (&addressQName) QualifiedName(nullAtom, "address", xhtmlNS); 152 new (&appletQName) QualifiedName(nullAtom, "applet", xhtmlNS); 153 new (&areaQName) QualifiedName(nullAtom, "area", xhtmlNS); 154 new (&bQName) QualifiedName(nullAtom, "b", xhtmlNS); 155 new (&baseQName) QualifiedName(nullAtom, "base", xhtmlNS); 156 new (&basefontQName) QualifiedName(nullAtom, "basefont", xhtmlNS); 157 new (&bdoQName) QualifiedName(nullAtom, "bdo", xhtmlNS); 158 new (&bigQName) QualifiedName(nullAtom, "big", xhtmlNS); 159 new (&blockquoteQName) QualifiedName(nullAtom, "blockquote", xhtmlNS); 160 new (&bodyQName) QualifiedName(nullAtom, "body", xhtmlNS); 161 new (&brQName) QualifiedName(nullAtom, "br", xhtmlNS); 162 new (&buttonQName) QualifiedName(nullAtom, "button", xhtmlNS); 163 new (&canvasQName) QualifiedName(nullAtom, "canvas", xhtmlNS); 164 new (&captionQName) QualifiedName(nullAtom, "caption", xhtmlNS); 165 new (¢erQName) QualifiedName(nullAtom, "center", xhtmlNS); 166 new (&citeQName) QualifiedName(nullAtom, "cite", xhtmlNS); 167 new (&codeQName) QualifiedName(nullAtom, "code", xhtmlNS); 168 new (&colQName) QualifiedName(nullAtom, "col", xhtmlNS); 169 new (&colgroupQName) QualifiedName(nullAtom, "colgroup", xhtmlNS); 170 new (&ddQName) QualifiedName(nullAtom, "dd", xhtmlNS); 171 new (&delQName) QualifiedName(nullAtom, "del", xhtmlNS); 172 new (&dfnQName) QualifiedName(nullAtom, "dfn", xhtmlNS); 173 new (&dirQName) QualifiedName(nullAtom, "dir", xhtmlNS); 174 new (&divQName) QualifiedName(nullAtom, "div", xhtmlNS); 175 new (&dlQName) QualifiedName(nullAtom, "dl", xhtmlNS); 176 new (&dtQName) QualifiedName(nullAtom, "dt", xhtmlNS); 177 new (&emQName) QualifiedName(nullAtom, "em", xhtmlNS); 178 new (&embedQName) QualifiedName(nullAtom, "embed", xhtmlNS); 179 new (&fieldsetQName) QualifiedName(nullAtom, "fieldset", xhtmlNS); 180 new (&fontQName) QualifiedName(nullAtom, "font", xhtmlNS); 181 new (&formQName) QualifiedName(nullAtom, "form", xhtmlNS); 182 new (&frameQName) QualifiedName(nullAtom, "frame", xhtmlNS); 183 new (&framesetQName) QualifiedName(nullAtom, "frameset", xhtmlNS); 184 new (&headQName) QualifiedName(nullAtom, "head", xhtmlNS); 185 new (&h1QName) QualifiedName(nullAtom, "h1", xhtmlNS); 186 new (&h2QName) QualifiedName(nullAtom, "h2", xhtmlNS); 187 new (&h3QName) QualifiedName(nullAtom, "h3", xhtmlNS); 188 new (&h4QName) QualifiedName(nullAtom, "h4", xhtmlNS); 189 new (&h5QName) QualifiedName(nullAtom, "h5", xhtmlNS); 190 new (&h6QName) QualifiedName(nullAtom, "h6", xhtmlNS); 191 new (&hrQName) QualifiedName(nullAtom, "hr", xhtmlNS); 192 new (&htmlQName) QualifiedName(nullAtom, "html", xhtmlNS); 193 new (&iQName) QualifiedName(nullAtom, "i", xhtmlNS); 194 new (&iframeQName) QualifiedName(nullAtom, "iframe", xhtmlNS); 195 new (&imgQName) QualifiedName(nullAtom, "img", xhtmlNS); 196 new (&inputQName) QualifiedName(nullAtom, "input", xhtmlNS); 197 new (&insQName) QualifiedName(nullAtom, "ins", xhtmlNS); 198 new (&isindexQName) QualifiedName(nullAtom, "isindex", xhtmlNS); 199 new (&kbdQName) QualifiedName(nullAtom, "kbd", xhtmlNS); 200 new (&keygenQName) QualifiedName(nullAtom, "keygen", xhtmlNS); 201 new (&labelQName) QualifiedName(nullAtom, "label", xhtmlNS); 202 new (&layerQName) QualifiedName(nullAtom, "layer", xhtmlNS); 203 new (&legendQName) QualifiedName(nullAtom, "legend", xhtmlNS); 204 new (&liQName) QualifiedName(nullAtom, "li", xhtmlNS); 205 new (&linkQName) QualifiedName(nullAtom, "link", xhtmlNS); 206 new (&mapQName) QualifiedName(nullAtom, "map", xhtmlNS); 207 new (&marqueeQName) QualifiedName(nullAtom, "marquee", xhtmlNS); 208 new (&menuQName) QualifiedName(nullAtom, "menu", xhtmlNS); 209 new (&metaQName) QualifiedName(nullAtom, "meta", xhtmlNS); 210 new (&nobrQName) QualifiedName(nullAtom, "nobr", xhtmlNS); 211 new (&noembedQName) QualifiedName(nullAtom, "noembed", xhtmlNS); 212 new (&noframesQName) QualifiedName(nullAtom, "noframes", xhtmlNS); 213 new (&nolayerQName) QualifiedName(nullAtom, "nolayer", xhtmlNS); 214 new (&noscriptQName) QualifiedName(nullAtom, "noscript", xhtmlNS); 215 new (&objectQName) QualifiedName(nullAtom, "object", xhtmlNS); 216 new (&olQName) QualifiedName(nullAtom, "ol", xhtmlNS); 217 new (&optgroupQName) QualifiedName(nullAtom, "optgroup", xhtmlNS); 218 new (&optionQName) QualifiedName(nullAtom, "option", xhtmlNS); 219 new (&pQName) QualifiedName(nullAtom, "p", xhtmlNS); 220 new (¶mQName) QualifiedName(nullAtom, "param", xhtmlNS); 221 new (&plaintextQName) QualifiedName(nullAtom, "plaintext", xhtmlNS); 222 new (&preQName) QualifiedName(nullAtom, "pre", xhtmlNS); 223 new (&qQName) QualifiedName(nullAtom, "q", xhtmlNS); 224 new (&sQName) QualifiedName(nullAtom, "s", xhtmlNS); 225 new (&sampQName) QualifiedName(nullAtom, "samp", xhtmlNS); 226 new (&scriptQName) QualifiedName(nullAtom, "script", xhtmlNS); 227 new (&selectQName) QualifiedName(nullAtom, "select", xhtmlNS); 228 new (&smallQName) QualifiedName(nullAtom, "small", xhtmlNS); 229 new (&spanQName) QualifiedName(nullAtom, "span", xhtmlNS); 230 new (&strikeQName) QualifiedName(nullAtom, "strike", xhtmlNS); 231 new (&strongQName) QualifiedName(nullAtom, "strong", xhtmlNS); 232 new (&styleQName) QualifiedName(nullAtom, "style", xhtmlNS); 233 new (&subQName) QualifiedName(nullAtom, "sub", xhtmlNS); 234 new (&supQName) QualifiedName(nullAtom, "sup", xhtmlNS); 235 new (&tableQName) QualifiedName(nullAtom, "table", xhtmlNS); 236 new (&tbodyQName) QualifiedName(nullAtom, "tbody", xhtmlNS); 237 new (&tdQName) QualifiedName(nullAtom, "td", xhtmlNS); 238 new (&textareaQName) QualifiedName(nullAtom, "textarea", xhtmlNS); 239 new (&tfootQName) QualifiedName(nullAtom, "tfoot", xhtmlNS); 240 new (&thQName) QualifiedName(nullAtom, "th", xhtmlNS); 241 new (&theadQName) QualifiedName(nullAtom, "thead", xhtmlNS); 242 new (&titleQName) QualifiedName(nullAtom, "title", xhtmlNS); 243 new (&trQName) QualifiedName(nullAtom, "tr", xhtmlNS); 244 new (&ttQName) QualifiedName(nullAtom, "tt", xhtmlNS); 245 new (&uQName) QualifiedName(nullAtom, "u", xhtmlNS); 246 new (&ulQName) QualifiedName(nullAtom, "ul", xhtmlNS); 247 new (&varQName) QualifiedName(nullAtom, "var", xhtmlNS); 248 new (&wbrQName) QualifiedName(nullAtom, "wbr", xhtmlNS); 249 new (&xmpQName) QualifiedName(nullAtom, "xmp", xhtmlNS); 250 initialized = true; 251 } 32 252 } 33 253 34 35 // Tag names.36 const QualifiedName& HTMLNames::a()37 {38 static QualifiedName a(nullAtom, "a", xhtmlNamespaceURI());39 return a;40 254 } 41 42 const QualifiedName& HTMLNames::address()43 {44 static QualifiedName address(nullAtom, "address", xhtmlNamespaceURI());45 return address;46 }47 48 const QualifiedName& HTMLNames::applet()49 {50 static QualifiedName applet(nullAtom, "applet", xhtmlNamespaceURI());51 return applet;52 }53 54 const QualifiedName& HTMLNames::area()55 {56 static QualifiedName area(nullAtom, "area", xhtmlNamespaceURI());57 return area;58 }59 60 const QualifiedName& HTMLNames::b()61 {62 static QualifiedName b(nullAtom, "b", xhtmlNamespaceURI());63 return b;64 }65 66 const QualifiedName& HTMLNames::base()67 {68 static QualifiedName base(nullAtom, "base", xhtmlNamespaceURI());69 return base;70 }71 72 const QualifiedName& HTMLNames::basefont()73 {74 static QualifiedName basefont(nullAtom, "basefont", xhtmlNamespaceURI());75 return basefont;76 }77 78 const QualifiedName& HTMLNames::big()79 {80 static QualifiedName big(nullAtom, "big", xhtmlNamespaceURI());81 return big;82 }83 84 const QualifiedName& HTMLNames::blockquote()85 {86 static QualifiedName blockquote(nullAtom, "blockquote", xhtmlNamespaceURI());87 return blockquote;88 }89 90 const QualifiedName& HTMLNames::body()91 {92 static QualifiedName body(nullAtom, "body", xhtmlNamespaceURI());93 return body;94 }95 96 const QualifiedName& HTMLNames::br()97 {98 static QualifiedName br(nullAtom, "br", xhtmlNamespaceURI());99 return br;100 }101 102 const QualifiedName& HTMLNames::button()103 {104 static QualifiedName button(nullAtom, "button", xhtmlNamespaceURI());105 return button;106 }107 108 const QualifiedName& HTMLNames::canvas()109 {110 static QualifiedName canvas(nullAtom, "canvas", xhtmlNamespaceURI());111 return canvas;112 }113 114 const QualifiedName& HTMLNames::caption()115 {116 static QualifiedName caption(nullAtom, "caption", xhtmlNamespaceURI());117 return caption;118 }119 120 const QualifiedName& HTMLNames::center()121 {122 static QualifiedName center(nullAtom, "center", xhtmlNamespaceURI());123 return center;124 }125 126 const QualifiedName& HTMLNames::code()127 {128 static QualifiedName code(nullAtom, "code", xhtmlNamespaceURI());129 return code;130 }131 132 const QualifiedName& HTMLNames::col()133 {134 static QualifiedName col(nullAtom, "col", xhtmlNamespaceURI());135 return col;136 }137 138 const QualifiedName& HTMLNames::colgroup()139 {140 static QualifiedName colgroup(nullAtom, "colgroup", xhtmlNamespaceURI());141 return colgroup;142 }143 144 const QualifiedName& HTMLNames::dd()145 {146 static QualifiedName dd(nullAtom, "dd", xhtmlNamespaceURI());147 return dd;148 }149 150 const QualifiedName& HTMLNames::del()151 {152 static QualifiedName del(nullAtom, "del", xhtmlNamespaceURI());153 return del;154 }155 156 const QualifiedName& HTMLNames::dfn()157 {158 static QualifiedName dfn(nullAtom, "dfn", xhtmlNamespaceURI());159 return dfn;160 }161 162 const QualifiedName& HTMLNames::dir()163 {164 static QualifiedName dir(nullAtom, "dir", xhtmlNamespaceURI());165 return dir;166 }167 168 const QualifiedName& HTMLNames::div()169 {170 static QualifiedName div(nullAtom, "div", xhtmlNamespaceURI());171 return div;172 }173 174 const QualifiedName& HTMLNames::dl()175 {176 static QualifiedName dl(nullAtom, "dl", xhtmlNamespaceURI());177 return dl;178 }179 180 const QualifiedName& HTMLNames::dt()181 {182 static QualifiedName dt(nullAtom, "dt", xhtmlNamespaceURI());183 return dt;184 }185 186 const QualifiedName& HTMLNames::em()187 {188 static QualifiedName em(nullAtom, "em", xhtmlNamespaceURI());189 return em;190 }191 192 const QualifiedName& HTMLNames::embed()193 {194 static QualifiedName embed(nullAtom, "embed", xhtmlNamespaceURI());195 return embed;196 }197 198 const QualifiedName& HTMLNames::fieldset()199 {200 static QualifiedName fieldset(nullAtom, "fieldset", xhtmlNamespaceURI());201 return fieldset;202 }203 204 const QualifiedName& HTMLNames::font()205 {206 static QualifiedName font(nullAtom, "font", xhtmlNamespaceURI());207 return font;208 }209 210 const QualifiedName& HTMLNames::form()211 {212 static QualifiedName form(nullAtom, "form", xhtmlNamespaceURI());213 return form;214 }215 216 const QualifiedName& HTMLNames::frame()217 {218 static QualifiedName frame(nullAtom, "frame", xhtmlNamespaceURI());219 return frame;220 }221 222 const QualifiedName& HTMLNames::frameset()223 {224 static QualifiedName frameset(nullAtom, "frameset", xhtmlNamespaceURI());225 return frameset;226 }227 228 const QualifiedName& HTMLNames::head()229 {230 static QualifiedName head(nullAtom, "head", xhtmlNamespaceURI());231 return head;232 }233 234 const QualifiedName& HTMLNames::h1()235 {236 static QualifiedName h1(nullAtom, "h1", xhtmlNamespaceURI());237 return h1;238 }239 240 const QualifiedName& HTMLNames::h2()241 {242 static QualifiedName h2(nullAtom, "h2", xhtmlNamespaceURI());243 return h2;244 }245 246 const QualifiedName& HTMLNames::h3()247 {248 static QualifiedName h3(nullAtom, "h3", xhtmlNamespaceURI());249 return h3;250 }251 252 const QualifiedName& HTMLNames::h4()253 {254 static QualifiedName h4(nullAtom, "h4", xhtmlNamespaceURI());255 return h4;256 }257 258 const QualifiedName& HTMLNames::h5()259 {260 static QualifiedName h5(nullAtom, "h5", xhtmlNamespaceURI());261 return h5;262 }263 264 const QualifiedName& HTMLNames::h6()265 {266 static QualifiedName h6(nullAtom, "h6", xhtmlNamespaceURI());267 return h6;268 }269 270 const QualifiedName& HTMLNames::hr()271 {272 static QualifiedName hr(nullAtom, "hr", xhtmlNamespaceURI());273 return hr;274 }275 276 const QualifiedName& HTMLNames::html()277 {278 static QualifiedName html(nullAtom, "html", xhtmlNamespaceURI());279 return html;280 }281 282 const QualifiedName& HTMLNames::i()283 {284 static QualifiedName i(nullAtom, "i", xhtmlNamespaceURI());285 return i;286 }287 288 const QualifiedName& HTMLNames::iframe()289 {290 static QualifiedName iframe(nullAtom, "iframe", xhtmlNamespaceURI());291 return iframe;292 }293 294 const QualifiedName& HTMLNames::img()295 {296 static QualifiedName img(nullAtom, "img", xhtmlNamespaceURI());297 return img;298 }299 300 const QualifiedName& HTMLNames::input()301 {302 static QualifiedName input(nullAtom, "input", xhtmlNamespaceURI());303 return input;304 }305 306 const QualifiedName& HTMLNames::ins()307 {308 static QualifiedName ins(nullAtom, "ins", xhtmlNamespaceURI());309 return ins;310 }311 312 const QualifiedName& HTMLNames::isindex()313 {314 static QualifiedName isindex(nullAtom, "isindex", xhtmlNamespaceURI());315 return isindex;316 }317 318 const QualifiedName& HTMLNames::kbd()319 {320 static QualifiedName kbd(nullAtom, "kbd", xhtmlNamespaceURI());321 return kbd;322 }323 324 const QualifiedName& HTMLNames::keygen()325 {326 static QualifiedName keygen(nullAtom, "keygen", xhtmlNamespaceURI());327 return keygen;328 }329 330 const QualifiedName& HTMLNames::label()331 {332 static QualifiedName label(nullAtom, "label", xhtmlNamespaceURI());333 return label;334 }335 336 const QualifiedName& HTMLNames::legend()337 {338 static QualifiedName legend(nullAtom, "legend", xhtmlNamespaceURI());339 return legend;340 }341 342 const QualifiedName& HTMLNames::li()343 {344 static QualifiedName li(nullAtom, "li", xhtmlNamespaceURI());345 return li;346 }347 348 const QualifiedName& HTMLNames::link()349 {350 static QualifiedName link(nullAtom, "link", xhtmlNamespaceURI());351 return link;352 }353 354 const QualifiedName& HTMLNames::map()355 {356 static QualifiedName map(nullAtom, "map", xhtmlNamespaceURI());357 return map;358 }359 360 const QualifiedName& HTMLNames::marquee()361 {362 static QualifiedName marquee(nullAtom, "marquee", xhtmlNamespaceURI());363 return marquee;364 }365 366 const QualifiedName& HTMLNames::menu()367 {368 static QualifiedName menu(nullAtom, "menu", xhtmlNamespaceURI());369 return menu;370 }371 372 const QualifiedName& HTMLNames::meta()373 {374 static QualifiedName meta(nullAtom, "meta", xhtmlNamespaceURI());375 return meta;376 }377 378 const QualifiedName& HTMLNames::noembed()379 {380 static QualifiedName noembed(nullAtom, "noembed", xhtmlNamespaceURI());381 return noembed;382 }383 384 const QualifiedName& HTMLNames::noframes()385 {386 static QualifiedName noframes(nullAtom, "noframes", xhtmlNamespaceURI());387 return noframes;388 }389 390 const QualifiedName& HTMLNames::noscript()391 {392 static QualifiedName noscript(nullAtom, "noscript", xhtmlNamespaceURI());393 return noscript;394 }395 396 const QualifiedName& HTMLNames::object()397 {398 static QualifiedName object(nullAtom, "object", xhtmlNamespaceURI());399 return object;400 }401 402 const QualifiedName& HTMLNames::ol()403 {404 static QualifiedName ol(nullAtom, "ol", xhtmlNamespaceURI());405 return ol;406 }407 408 const QualifiedName& HTMLNames::optgroup()409 {410 static QualifiedName optgroup(nullAtom, "optgroup", xhtmlNamespaceURI());411 return optgroup;412 }413 414 const QualifiedName& HTMLNames::p()415 {416 static QualifiedName p(nullAtom, "p", xhtmlNamespaceURI());417 return p;418 }419 420 const QualifiedName& HTMLNames::param()421 {422 static QualifiedName param(nullAtom, "param", xhtmlNamespaceURI());423 return param;424 }425 426 const QualifiedName& HTMLNames::pre()427 {428 static QualifiedName pre(nullAtom, "pre", xhtmlNamespaceURI());429 return pre;430 }431 432 const QualifiedName& HTMLNames::q()433 {434 static QualifiedName q(nullAtom, "q", xhtmlNamespaceURI());435 return q;436 }437 438 const QualifiedName& HTMLNames::s()439 {440 static QualifiedName s(nullAtom, "s", xhtmlNamespaceURI());441 return s;442 }443 444 const QualifiedName& HTMLNames::samp()445 {446 static QualifiedName samp(nullAtom, "samp", xhtmlNamespaceURI());447 return samp;448 }449 450 const QualifiedName& HTMLNames::script()451 {452 static QualifiedName script(nullAtom, "script", xhtmlNamespaceURI());453 return script;454 }455 456 const QualifiedName& HTMLNames::select()457 {458 static QualifiedName select(nullAtom, "select", xhtmlNamespaceURI());459 return select;460 }461 462 const QualifiedName& HTMLNames::small()463 {464 static QualifiedName small(nullAtom, "small", xhtmlNamespaceURI());465 return small;466 }467 468 const QualifiedName& HTMLNames::strike()469 {470 static QualifiedName strike(nullAtom, "strike", xhtmlNamespaceURI());471 return strike;472 }473 474 const QualifiedName& HTMLNames::strong()475 {476 static QualifiedName strong(nullAtom, "strong", xhtmlNamespaceURI());477 return strong;478 }479 480 const QualifiedName& HTMLNames::style()481 {482 static QualifiedName style(nullAtom, "style", xhtmlNamespaceURI());483 return style;484 }485 486 const QualifiedName& HTMLNames::table()487 {488 static QualifiedName table(nullAtom, "table", xhtmlNamespaceURI());489 return table;490 }491 492 const QualifiedName& HTMLNames::tbody()493 {494 static QualifiedName tbody(nullAtom, "tbody", xhtmlNamespaceURI());495 return tbody;496 }497 498 const QualifiedName& HTMLNames::td()499 {500 static QualifiedName td(nullAtom, "td", xhtmlNamespaceURI());501 return td;502 }503 504 const QualifiedName& HTMLNames::textarea()505 {506 static QualifiedName textarea(nullAtom, "textarea", xhtmlNamespaceURI());507 return textarea;508 }509 510 const QualifiedName& HTMLNames::tfoot()511 {512 static QualifiedName tfoot(nullAtom, "tfoot", xhtmlNamespaceURI());513 return tfoot;514 }515 516 const QualifiedName& HTMLNames::th()517 {518 static QualifiedName th(nullAtom, "th", xhtmlNamespaceURI());519 return th;520 }521 522 const QualifiedName& HTMLNames::thead()523 {524 static QualifiedName thead(nullAtom, "thead", xhtmlNamespaceURI());525 return thead;526 }527 528 const QualifiedName& HTMLNames::title()529 {530 static QualifiedName title(nullAtom, "title", xhtmlNamespaceURI());531 return title;532 }533 534 const QualifiedName& HTMLNames::tr()535 {536 static QualifiedName tr(nullAtom, "tr", xhtmlNamespaceURI());537 return tr;538 }539 540 const QualifiedName& HTMLNames::tt()541 {542 static QualifiedName tt(nullAtom, "tt", xhtmlNamespaceURI());543 return tt;544 }545 546 const QualifiedName& HTMLNames::u()547 {548 static QualifiedName u(nullAtom, "u", xhtmlNamespaceURI());549 return u;550 }551 552 const QualifiedName& HTMLNames::ul()553 {554 static QualifiedName ul(nullAtom, "ul", xhtmlNamespaceURI());555 return ul;556 }557 558 const QualifiedName& HTMLNames::var()559 {560 static QualifiedName var(nullAtom, "var", xhtmlNamespaceURI());561 return var;562 }563 564 const QualifiedName& HTMLNames::xmp()565 {566 static QualifiedName xmp(nullAtom, "xmp", xhtmlNamespaceURI());567 return xmp;568 }569 570 } -
trunk/WebCore/khtml/html/htmlnames.h
r9402 r9639 23 23 #define HTMLNAMES_H 24 24 25 #include " xml/dom_elementimpl.h"25 #include "dom_qname.h" 26 26 27 27 namespace DOM … … 30 30 class QualifiedName; 31 31 32 // The globals. 33 // Define external global variables for all HTML names above. 34 #if !KHTML_HTMLNAMES_HIDE_GLOBALS 35 extern const AtomicString xhtmlNamespaceURIAtom; 36 extern const QualifiedName aQName; 37 extern const QualifiedName abbrQName; 38 extern const QualifiedName acronymQName; 39 extern const QualifiedName addressQName; 40 extern const QualifiedName appletQName; 41 extern const QualifiedName areaQName; 42 extern const QualifiedName bQName; 43 extern const QualifiedName baseQName; 44 extern const QualifiedName basefontQName; 45 extern const QualifiedName bdoQName; 46 extern const QualifiedName bigQName; 47 extern const QualifiedName blockquoteQName; 48 extern const QualifiedName bodyQName; 49 extern const QualifiedName brQName; 50 extern const QualifiedName buttonQName; 51 extern const QualifiedName canvasQName; 52 extern const QualifiedName captionQName; 53 extern const QualifiedName centerQName; 54 extern const QualifiedName citeQName; 55 extern const QualifiedName codeQName; 56 extern const QualifiedName colQName; 57 extern const QualifiedName colgroupQName; 58 extern const QualifiedName ddQName; 59 extern const QualifiedName delQName; 60 extern const QualifiedName dfnQName; 61 extern const QualifiedName dirQName; 62 extern const QualifiedName divQName; 63 extern const QualifiedName dlQName; 64 extern const QualifiedName dtQName; 65 extern const QualifiedName emQName; 66 extern const QualifiedName embedQName; 67 extern const QualifiedName fieldsetQName; 68 extern const QualifiedName fontQName; 69 extern const QualifiedName formQName; 70 extern const QualifiedName frameQName; 71 extern const QualifiedName framesetQName; 72 extern const QualifiedName headQName; 73 extern const QualifiedName h1QName; 74 extern const QualifiedName h2QName; 75 extern const QualifiedName h3QName; 76 extern const QualifiedName h4QName; 77 extern const QualifiedName h5QName; 78 extern const QualifiedName h6QName; 79 extern const QualifiedName hrQName; 80 extern const QualifiedName htmlQName; 81 extern const QualifiedName iQName; 82 extern const QualifiedName iframeQName; 83 extern const QualifiedName imgQName; 84 extern const QualifiedName inputQName; 85 extern const QualifiedName insQName; 86 extern const QualifiedName isindexQName; 87 extern const QualifiedName kbdQName; 88 extern const QualifiedName keygenQName; 89 extern const QualifiedName labelQName; 90 extern const QualifiedName layerQName; 91 extern const QualifiedName legendQName; 92 extern const QualifiedName liQName; 93 extern const QualifiedName linkQName; 94 extern const QualifiedName mapQName; 95 extern const QualifiedName marqueeQName; 96 extern const QualifiedName menuQName; 97 extern const QualifiedName metaQName; 98 extern const QualifiedName nobrQName; 99 extern const QualifiedName noembedQName; 100 extern const QualifiedName noframesQName; 101 extern const QualifiedName nolayerQName; 102 extern const QualifiedName noscriptQName; 103 extern const QualifiedName objectQName; 104 extern const QualifiedName olQName; 105 extern const QualifiedName optgroupQName; 106 extern const QualifiedName optionQName; 107 extern const QualifiedName pQName; 108 extern const QualifiedName paramQName; 109 extern const QualifiedName plaintextQName; 110 extern const QualifiedName preQName; 111 extern const QualifiedName qQName; 112 extern const QualifiedName sQName; 113 extern const QualifiedName sampQName; 114 extern const QualifiedName scriptQName; 115 extern const QualifiedName selectQName; 116 extern const QualifiedName smallQName; 117 extern const QualifiedName spanQName; 118 extern const QualifiedName strikeQName; 119 extern const QualifiedName strongQName; 120 extern const QualifiedName styleQName; 121 extern const QualifiedName subQName; 122 extern const QualifiedName supQName; 123 extern const QualifiedName tableQName; 124 extern const QualifiedName tbodyQName; 125 extern const QualifiedName tdQName; 126 extern const QualifiedName textareaQName; 127 extern const QualifiedName tfootQName; 128 extern const QualifiedName thQName; 129 extern const QualifiedName theadQName; 130 extern const QualifiedName titleQName; 131 extern const QualifiedName trQName; 132 extern const QualifiedName ttQName; 133 extern const QualifiedName uQName; 134 extern const QualifiedName ulQName; 135 extern const QualifiedName varQName; 136 extern const QualifiedName wbrQName; 137 extern const QualifiedName xmpQName; 138 139 #endif 140 141 // FIXME: Make this a namespace instead of a class. 32 142 class HTMLNames 33 143 { 34 144 public: 145 #if !KHTML_HTMLNAMES_HIDE_GLOBALS 35 146 // The namespace URI. 36 static const AtomicString& xhtmlNamespaceURI() ;147 static const AtomicString& xhtmlNamespaceURI() { return xhtmlNamespaceURIAtom; } 37 148 38 // Full tag names. 39 static const QualifiedName& a(); 40 static const QualifiedName& address(); 41 static const QualifiedName& applet(); 42 static const QualifiedName& area(); 43 static const QualifiedName& b(); 44 static const QualifiedName& base(); 45 static const QualifiedName& basefont(); 46 static const QualifiedName& big(); 47 static const QualifiedName& blockquote(); 48 static const QualifiedName& body(); 49 static const QualifiedName& br(); 50 static const QualifiedName& button(); 51 static const QualifiedName& canvas(); 52 static const QualifiedName& caption(); 53 static const QualifiedName& center(); 54 static const QualifiedName& code(); 55 static const QualifiedName& col(); 56 static const QualifiedName& colgroup(); 57 static const QualifiedName& dd(); 58 static const QualifiedName& del(); 59 static const QualifiedName& dfn(); 60 static const QualifiedName& dir(); 61 static const QualifiedName& div(); 62 static const QualifiedName& dl(); 63 static const QualifiedName& dt(); 64 static const QualifiedName& em(); 65 static const QualifiedName& embed(); 66 static const QualifiedName& fieldset(); 67 static const QualifiedName& font(); 68 static const QualifiedName& form(); 69 static const QualifiedName& frame(); 70 static const QualifiedName& frameset(); 71 static const QualifiedName& head(); 72 static const QualifiedName& h1(); 73 static const QualifiedName& h2(); 74 static const QualifiedName& h3(); 75 static const QualifiedName& h4(); 76 static const QualifiedName& h5(); 77 static const QualifiedName& h6(); 78 static const QualifiedName& hr(); 79 static const QualifiedName& html(); 80 static const QualifiedName& i(); 81 static const QualifiedName& iframe(); 82 static const QualifiedName& img(); 83 static const QualifiedName& input(); 84 static const QualifiedName& ins(); 85 static const QualifiedName& isindex(); 86 static const QualifiedName& kbd(); 87 static const QualifiedName& keygen(); 88 static const QualifiedName& label(); 89 static const QualifiedName& legend(); 90 static const QualifiedName& li(); 91 static const QualifiedName& link(); 92 static const QualifiedName& map(); 93 static const QualifiedName& marquee(); 94 static const QualifiedName& menu(); 95 static const QualifiedName& meta(); 96 static const QualifiedName& noembed(); 97 static const QualifiedName& noframes(); 98 static const QualifiedName& noscript(); 99 static const QualifiedName& object(); 100 static const QualifiedName& ol(); 101 static const QualifiedName& optgroup(); 102 static const QualifiedName& option(); 103 static const QualifiedName& p(); 104 static const QualifiedName& param(); 105 static const QualifiedName& pre(); 106 static const QualifiedName& q(); 107 static const QualifiedName& s(); 108 static const QualifiedName& samp(); 109 static const QualifiedName& script(); 110 static const QualifiedName& select(); 111 static const QualifiedName& small(); 112 static const QualifiedName& strike(); 113 static const QualifiedName& strong(); 114 static const QualifiedName& style(); 115 static const QualifiedName& table(); 116 static const QualifiedName& tbody(); 117 static const QualifiedName& td(); 118 static const QualifiedName& textarea(); 119 static const QualifiedName& tfoot(); 120 static const QualifiedName& th(); 121 static const QualifiedName& thead(); 122 static const QualifiedName& title(); 123 static const QualifiedName& tr(); 124 static const QualifiedName& tt(); 125 static const QualifiedName& u(); 126 static const QualifiedName& ul(); 127 static const QualifiedName& var(); 128 static const QualifiedName& xmp(); 149 // Full tag names. 150 #define DEFINE_GETTER(name) \ 151 static const QualifiedName& name() { return name ## QName; } 152 153 DEFINE_GETTER(a) 154 DEFINE_GETTER(abbr) 155 DEFINE_GETTER(acronym) 156 DEFINE_GETTER(address) 157 DEFINE_GETTER(applet) 158 DEFINE_GETTER(area) 159 DEFINE_GETTER(b) 160 DEFINE_GETTER(base) 161 DEFINE_GETTER(basefont) 162 DEFINE_GETTER(bdo) 163 DEFINE_GETTER(big) 164 DEFINE_GETTER(blockquote) 165 DEFINE_GETTER(body) 166 DEFINE_GETTER(br) 167 DEFINE_GETTER(button) 168 DEFINE_GETTER(canvas) 169 DEFINE_GETTER(caption) 170 DEFINE_GETTER(center) 171 DEFINE_GETTER(cite) 172 DEFINE_GETTER(code) 173 DEFINE_GETTER(col) 174 DEFINE_GETTER(colgroup) 175 DEFINE_GETTER(dd) 176 DEFINE_GETTER(del) 177 DEFINE_GETTER(dfn) 178 DEFINE_GETTER(dir) 179 DEFINE_GETTER(div) 180 DEFINE_GETTER(dl) 181 DEFINE_GETTER(dt) 182 DEFINE_GETTER(em) 183 DEFINE_GETTER(embed) 184 DEFINE_GETTER(fieldset) 185 DEFINE_GETTER(font) 186 DEFINE_GETTER(form) 187 DEFINE_GETTER(frame) 188 DEFINE_GETTER(frameset) 189 DEFINE_GETTER(head) 190 DEFINE_GETTER(h1) 191 DEFINE_GETTER(h2) 192 DEFINE_GETTER(h3) 193 DEFINE_GETTER(h4) 194 DEFINE_GETTER(h5) 195 DEFINE_GETTER(h6) 196 DEFINE_GETTER(hr) 197 DEFINE_GETTER(html) 198 DEFINE_GETTER(i) 199 DEFINE_GETTER(iframe) 200 DEFINE_GETTER(img) 201 DEFINE_GETTER(input) 202 DEFINE_GETTER(ins) 203 DEFINE_GETTER(isindex) 204 DEFINE_GETTER(kbd) 205 DEFINE_GETTER(keygen) 206 DEFINE_GETTER(label) 207 DEFINE_GETTER(layer) 208 DEFINE_GETTER(legend) 209 DEFINE_GETTER(li) 210 DEFINE_GETTER(link) 211 DEFINE_GETTER(map) 212 DEFINE_GETTER(marquee) 213 DEFINE_GETTER(menu) 214 DEFINE_GETTER(meta) 215 DEFINE_GETTER(nobr) 216 DEFINE_GETTER(noembed) 217 DEFINE_GETTER(noframes) 218 DEFINE_GETTER(nolayer) 219 DEFINE_GETTER(noscript) 220 DEFINE_GETTER(object) 221 DEFINE_GETTER(ol) 222 DEFINE_GETTER(optgroup) 223 DEFINE_GETTER(option) 224 DEFINE_GETTER(p) 225 DEFINE_GETTER(param) 226 DEFINE_GETTER(plaintext) 227 DEFINE_GETTER(pre) 228 DEFINE_GETTER(q) 229 DEFINE_GETTER(s) 230 DEFINE_GETTER(samp) 231 DEFINE_GETTER(script) 232 DEFINE_GETTER(select) 233 DEFINE_GETTER(small) 234 DEFINE_GETTER(span) 235 DEFINE_GETTER(strike) 236 DEFINE_GETTER(strong) 237 DEFINE_GETTER(style) 238 DEFINE_GETTER(sub) 239 DEFINE_GETTER(sup) 240 DEFINE_GETTER(table) 241 DEFINE_GETTER(tbody) 242 DEFINE_GETTER(td) 243 DEFINE_GETTER(textarea) 244 DEFINE_GETTER(tfoot) 245 DEFINE_GETTER(th) 246 DEFINE_GETTER(thead) 247 DEFINE_GETTER(title) 248 DEFINE_GETTER(tr) 249 DEFINE_GETTER(tt) 250 DEFINE_GETTER(u) 251 DEFINE_GETTER(ul) 252 DEFINE_GETTER(var) 253 DEFINE_GETTER(wbr) 254 DEFINE_GETTER(xmp) 129 255 130 256 // Attribute names. 257 #endif 258 259 // Init routine 260 static void init(); 131 261 }; 132 262 -
trunk/WebCore/khtml/html/htmlparser.cpp
r9156 r9639 45 45 #include "html/html_tableimpl.h" 46 46 #include "html/html_objectimpl.h" 47 #include "htmlfactory.h" 47 48 #include "xml/dom_textimpl.h" 48 49 #include "xml/dom_nodeimpl.h" 49 50 #include "misc/htmlhashes.h" 51 #include "misc/main_thread_malloc.h" 52 #include "misc/hashset.h" 50 53 #include "html/htmltokenizer.h" 51 54 #include "khtmlview.h" … … 56 59 #include "rendering/render_object.h" 57 60 61 #include "misc/pointerhash.h" 62 58 63 #include <kdebug.h> 59 64 #include <klocale.h> … … 70 75 { 71 76 public: 72 HTMLStackElem( int _id,73 74 75 77 HTMLStackElem(const AtomicString& _tagName, 78 int _level, 79 DOM::NodeImpl *_node, 80 HTMLStackElem * _next 76 81 ) 77 82 : 78 id(_id),83 tagName(_tagName), 79 84 level(_level), 80 85 strayTableContent(false), … … 83 88 { } 84 89 85 int id; 86 int level; 87 bool strayTableContent; 88 NodeImpl *node; 89 HTMLStackElem *next; 90 MAIN_THREAD_ALLOCATED; 91 92 AtomicString tagName; 93 int level; 94 bool strayTableContent; 95 NodeImpl* node; 96 HTMLStackElem* next; 90 97 }; 91 98 … … 113 120 * 114 121 */ 115 KHTMLParser::KHTMLParser(KHTMLView *_parent, DocumentPtr *doc, bool includesComments)122 HTMLParser::HTMLParser(KHTMLView *_parent, DocumentPtr *doc, bool includesComments) 116 123 : current(0), currentIsReferenced(false), includesCommentsInDOM(includesComments) 117 124 { 118 //kdDebug( 6035 ) << "parser constructor" << endl;119 #if SPEED_DEBUG > 0120 qt.start();121 #endif122 123 125 HTMLWidget = _parent; 124 126 document = doc; … … 130 132 } 131 133 132 KHTMLParser::KHTMLParser(DOM::DocumentFragmentImpl *i, DocumentPtr *doc, bool includesComments)134 HTMLParser::HTMLParser(DOM::DocumentFragmentImpl *i, DocumentPtr *doc, bool includesComments) 133 135 : current(0), currentIsReferenced(false), includesCommentsInDOM(includesComments) 134 136 { … … 144 146 } 145 147 146 KHTMLParser::~KHTMLParser() 147 { 148 #if SPEED_DEBUG > 0 149 kdDebug( ) << "TIME: parsing time was = " << qt.elapsed() << endl; 150 #endif 151 148 HTMLParser::~HTMLParser() 149 { 152 150 freeBlock(); 153 151 … … 160 158 } 161 159 162 void KHTMLParser::reset()160 void HTMLParser::reset() 163 161 { 164 162 setCurrent(doc()); 165 163 166 164 freeBlock(); 167 168 // before parsing, no tags are forbidden169 memset(forbiddenTag, 0, sizeof(forbiddenTag));170 165 171 166 inBody = false; … … 181 176 isindex = 0; 182 177 183 discard_until = 0;184 } 185 186 void KHTMLParser::setCurrent(DOM::NodeImpl *newCurrent)178 discard_until = nullAtom; 179 } 180 181 void HTMLParser::setCurrent(DOM::NodeImpl *newCurrent) 187 182 { 188 183 bool newCurrentIsReferenced = newCurrent && newCurrent != doc(); … … 195 190 } 196 191 197 void KHTMLParser::parseToken(Token *t)198 { 199 if (discard_until) {200 if (t->id == discard_until)201 discard_until = 0;192 void HTMLParser::parseToken(Token *t) 193 { 194 if (!discard_until.isNull()) { 195 if (t->tagName == discard_until && !t->beginTag) 196 discard_until = nullAtom; 202 197 203 198 // do not skip </iframe> 204 if ( discard_until || current->id() + ID_CLOSE_TAG != t->id)199 if (!discard_until.isNull() || (current->localName() != t->tagName)) 205 200 return; 206 201 } 207 202 208 #ifdef PARSER_DEBUG 209 kdDebug( 6035 ) << "\n\n==> parser: processing token " << getTagName(t->id).string() << "(" << t->id << ")" 210 << " current = " << getTagName(current->id()).string() << "(" << current->id() << ")" << endl; 211 kdDebug(6035) << " inBody=" << inBody << " haveFrameSet=" << haveFrameSet << endl; 212 #endif 213 214 // holy shit. apparently some sites use </br> instead of <br> 215 // be compatible with IE and NS 216 if (t->id == ID_BR + ID_CLOSE_TAG && doc()->inCompatMode()) 217 t->id = ID_BR; 218 219 if (t->id > ID_CLOSE_TAG) 220 { 203 // Apparently some sites use </br> instead of <br>. Be compatible with IE and Firefox and treat this like <br>. 204 if (t->isCloseTag(HTMLNames::br()) && doc()->inCompatMode()) 205 t->beginTag = true; 206 207 if (!t->beginTag) { 221 208 processCloseTag(t); 222 209 return; … … 224 211 225 212 // ignore spaces, if we're not inside a paragraph or other inline code 226 if( t->id == ID_TEXT && t->text ) { 227 if(inBody && !skipMode() && current->id() != ID_STYLE 228 && current->id() != ID_TITLE && current->id() != ID_SCRIPT && 229 !t->text->containsOnlyWhitespace()) 213 if (t->tagName == textAtom && t->text) { 214 if (inBody && !skipMode() && current->localName() != HTMLNames::style() && current->localName() != HTMLNames::title() && 215 current->localName() != HTMLNames::script() && !t->text->containsOnlyWhitespace()) 230 216 haveContent = true; 231 #ifdef PARSER_DEBUG 232 kdDebug(6035) << "length="<< t->text->l << " text='" << QConstString(t->text->s, t->text->l).string() << "'" << endl; 233 #endif 234 } 235 236 NodeImpl *n = getElement(t); 217 } 218 219 NodeImpl *n = getNode(t); 237 220 // just to be sure, and to catch currently unimplemented stuff 238 if (!n)221 if (!n) 239 222 return; 240 223 … … 242 225 243 226 // set attributes 244 if(n->isElementNode()) 245 { 246 ElementImpl *e = static_cast<ElementImpl *>(n); 227 if (n->isHTMLElement()) { 228 HTMLElementImpl *e = static_cast<HTMLElementImpl*>(n); 247 229 e->setAttributeMap(t->attrs); 248 230 249 231 // take care of optional close tags 250 if (endTagRequirement(e->id()) == DOM::OPTIONAL)251 popBlock(t-> id);232 if (e->endTagRequirement() == TagStatusOptional) 233 popBlock(t->tagName); 252 234 253 if (isHeaderTag(t-> id))235 if (isHeaderTag(t->tagName)) 254 236 // Do not allow two header tags to be nested if the intervening tags are inlines. 255 237 popNestedHeaderTag(); 256 238 } 257 239 258 // if this tag is forbidden inside the current context, pop 259 // blocks until we are allowed to add it... 260 while (blockStack && t->id <= ID_LAST_TAG && forbiddenTag[t->id]) { 261 #ifdef PARSER_DEBUG 262 kdDebug( 6035 ) << "t->id: " << t->id << " is forbidden :-( " << endl; 263 #endif 264 popOneBlock(); 265 } 266 267 if (!insertNode(n, t->flat)) 268 { 240 if (!insertNode(n, t->flat)) { 269 241 // we couldn't insert the node... 242 if (n->isElementNode()) { 243 ElementImpl* e = static_cast<ElementImpl*>(n); 244 e->setAttributeMap(0); 245 } 246 247 if (map == n) 248 map = 0; 249 250 if (form == n) 251 form = 0; 252 } 253 } 254 255 static bool isTableSection(NodeImpl* n) 256 { 257 return n->hasTagName(HTMLNames::tbody()) || n->hasTagName(HTMLNames::tfoot()) || n->hasTagName(HTMLNames::thead()); 258 } 259 260 static bool isTablePart(NodeImpl* n) 261 { 262 return n->hasTagName(HTMLNames::tr()) || n->hasTagName(HTMLNames::td()) || n->hasTagName(HTMLNames::th()) || 263 isTableSection(n); 264 } 265 266 static bool isTableRelated(NodeImpl* n) 267 { 268 return n->hasTagName(HTMLNames::table()) || isTablePart(n); 269 } 270 271 bool HTMLParser::insertNode(NodeImpl *n, bool flat) 272 { 273 SharedPtr<NodeImpl> protectNode(n); 274 275 const AtomicString& localName = n->localName(); 276 int tagPriority = n->isHTMLElement() ? static_cast<HTMLElementImpl*>(n)->tagPriority() : 0; 270 277 271 if(n->isElementNode())272 {273 ElementImpl *e = static_cast<ElementImpl *>(n);274 e->setAttributeMap(0);275 }276 277 #ifdef PARSER_DEBUG278 kdDebug( 6035 ) << "insertNode failed current=" << current->id() << ", new=" << n->id() << "!" << endl;279 #endif280 if (map == n)281 {282 #ifdef PARSER_DEBUG283 kdDebug( 6035 ) << " --> resetting map!" << endl;284 #endif285 map = 0;286 }287 if (form == n)288 {289 #ifdef PARSER_DEBUG290 kdDebug( 6035 ) << " --> resetting form!" << endl;291 #endif292 form = 0;293 }294 }295 }296 297 static bool isTableRelatedTag(int id)298 {299 return (id == ID_TR || id == ID_TD || id == ID_TABLE || id == ID_TBODY || id == ID_TFOOT || id == ID_THEAD ||300 id == ID_TH);301 }302 303 bool KHTMLParser::insertNode(NodeImpl *n, bool flat)304 {305 SharedPtr<NodeImpl> protectNode(n);306 307 int id = n->id();308 309 278 // let's be stupid and just try to insert it. 310 // this should work if the document is wellformed 311 #ifdef PARSER_DEBUG 312 NodeImpl *tmp = current; 313 #endif 279 // this should work if the document is well-formed 314 280 NodeImpl *newNode = current->addChild(n); 315 if ( newNode ) { 316 #ifdef PARSER_DEBUG 317 kdDebug( 6035 ) << "added " << n->nodeName().string() << " to " << tmp->nodeName().string() << ", new current=" << newNode->nodeName().string() << endl; 318 #endif 319 // don't push elements without end tag on the stack 320 if(tagPriority(id) != 0 && !flat) 321 { 322 pushBlock(id, tagPriority(id)); 281 if (newNode) { 282 // don't push elements without end tags (e.g., <img>) on the stack 283 if (tagPriority > 0 && !flat) { 284 pushBlock(localName, tagPriority); 323 285 if (newNode == current) 324 popBlock( id);286 popBlock(localName); 325 287 else 326 288 setCurrent(newNode); 327 #if SPEED_DEBUG < 2 328 if(!n->attached() && HTMLWidget) 289 if (!n->attached() && HTMLWidget) 329 290 n->attach(); 330 #endif331 291 } 332 292 else { 333 #if SPEED_DEBUG < 2 334 if(!n->attached() && HTMLWidget) 293 if (!n->attached() && HTMLWidget) 335 294 n->attach(); 336 295 if (n->maintainsState()) { … … 341 300 } 342 301 n->closeRenderer(); 343 #endif344 302 } 345 303 346 304 return true; 347 } else { 348 #ifdef PARSER_DEBUG 349 kdDebug( 6035 ) << "ADDING NODE FAILED!!!! current = " << current->nodeName().string() << ", new = " << n->nodeName().string() << endl; 350 #endif 351 // error handling... 352 HTMLElementImpl *e; 353 bool handled = false; 354 355 // switch according to the element to insert 356 switch(id) 357 { 358 case ID_TR: 359 case ID_TH: 360 case ID_TD: 361 if (inStrayTableContent && !isTableRelatedTag(current->id())) { 305 } else 306 return handleError(n, flat, localName, tagPriority); // Try to handle the error. 307 } 308 309 bool HTMLParser::handleError(NodeImpl* n, bool flat, const AtomicString& localName, int tagPriority) 310 { 311 // Error handling code. This is just ad hoc handling of specific parent/child combinations. 312 HTMLElementImpl *e; 313 bool handled = false; 314 315 // 1. Check out the element's tag name to decide how to deal with errors. 316 if (n->isTextNode()) { 317 if (current->hasTagName(HTMLNames::select())) 318 return false; 319 } else if (n->isHTMLElement()) { 320 HTMLElementImpl* h = static_cast<HTMLElementImpl*>(n); 321 if (h->hasLocalName(HTMLNames::tr()) || h->hasLocalName(HTMLNames::th()) || 322 h->hasLocalName(HTMLNames::td())) { 323 if (inStrayTableContent && !isTableRelated(current)) { 362 324 // pop out to the nearest enclosing table-related tag. 363 while (blockStack && !isTableRelated Tag(current->id()))325 while (blockStack && !isTableRelated(current)) 364 326 popOneBlock(); 365 327 return insertNode(n); 366 328 } 367 break; 368 case ID_COMMENT: 369 break; 370 case ID_HEAD: 371 // ### alllow not having <HTML> in at all, as per HTML spec 372 if (!current->isDocumentNode() && current->id() != ID_HTML ) 329 } else if (h->hasLocalName(HTMLNames::head())) { 330 if (!current->isDocumentNode() && !current->hasTagName(HTMLNames::html())) 373 331 return false; 374 break; 375 // We can deal with a base, meta and link element in the body, by just adding the element to head. 376 case ID_META: 377 case ID_LINK: 378 case ID_BASE: 379 if( !head ) 332 } else if (h->hasLocalName(HTMLNames::meta()) || h->hasLocalName(HTMLNames::link()) || h->hasLocalName(HTMLNames::base())) { 333 if (!head) 380 334 createHead(); 381 if( head ) { 382 if ( head->addChild(n) ) { 383 #if SPEED_DEBUG < 2 384 if(!n->attached() && HTMLWidget) 335 if (head) { 336 if (head->addChild(n)) { 337 if (!n->attached() && HTMLWidget) 385 338 n->attach(); 386 #endif387 339 return true; 388 } else { 389 return false; 390 } 391 } 392 break; 393 case ID_HTML: 340 } else 341 return false; 342 } 343 } else if (h->hasLocalName(HTMLNames::html())) { 394 344 if (!current->isDocumentNode() ) { 395 if ( doc()->firstChild()->id() == ID_HTML) {396 397 398 399 400 401 402 403 404 405 406 if ( changed)407 doc()->recalcStyle( NodeImpl::Inherit);408 345 if (doc()->firstChild()->hasTagName(HTMLNames::html())) { 346 // we have another <HTML> element.... apply attributes to existing one 347 // make sure we don't overwrite already existing attributes 348 NamedAttrMapImpl *map = static_cast<ElementImpl*>(n)->attributes(true); 349 NamedAttrMapImpl *bmap = static_cast<ElementImpl*>(doc()->firstChild())->attributes(false); 350 bool changed = false; 351 for (unsigned long l = 0; map && l < map->length(); ++l) { 352 AttributeImpl* it = map->attributeItem(l); 353 changed = !bmap->getAttributeItem(it->id()); 354 bmap->insertAttribute(it->clone(false)); 355 } 356 if (changed) 357 doc()->recalcStyle(NodeImpl::Inherit); 358 } 409 359 return false; 410 } 411 break; 412 case ID_TITLE: 413 case ID_STYLE: 414 if ( !head ) 360 } 361 } else if (h->hasLocalName(HTMLNames::title()) || h->hasLocalName(HTMLNames::style())) { 362 if (!head) 415 363 createHead(); 416 if ( head) {364 if (head) { 417 365 DOM::NodeImpl *newNode = head->addChild(n); 418 if ( newNode) {419 pushBlock( id, tagPriority(id));366 if (newNode) { 367 pushBlock(localName, tagPriority); 420 368 setCurrent(newNode); 421 #if SPEED_DEBUG < 2 422 if(!n->attached() && HTMLWidget) 369 if (!n->attached() && HTMLWidget) 423 370 n->attach(); 424 #endif425 371 } else { 426 #ifdef PARSER_DEBUG 427 kdDebug( 6035 ) << "adding style before to body failed!!!!" << endl; 428 #endif 429 discard_until = ID_STYLE + ID_CLOSE_TAG; 372 setSkipMode(HTMLNames::style()); 430 373 return false; 431 374 } 432 375 return true; 433 376 } else if(inBody) { 434 discard_until = ID_STYLE + ID_CLOSE_TAG;377 setSkipMode(HTMLNames::style()); 435 378 return false; 436 379 } 437 break; 438 // SCRIPT and OBJECT are allowed in the body. 439 case ID_BODY: 440 if(inBody && doc()->body()) { 380 } else if (h->hasLocalName(HTMLNames::body())) { 381 if (inBody && doc()->body()) { 441 382 // we have another <BODY> element.... apply attributes to existing one 442 383 // make sure we don't overwrite already existing attributes … … 450 391 bmap->insertAttribute(it->clone(false)); 451 392 } 452 if ( changed ) 453 doc()->recalcStyle( NodeImpl::Inherit ); 454 } else if ( current->isDocumentNode() ) 455 break; 456 return false; 457 break; 458 459 // the following is a hack to move non rendered elements 460 // outside of tables. 461 // needed for broken constructs like <table><form ...><tr>.... 462 case ID_INPUT: 463 { 464 ElementImpl *e = static_cast<ElementImpl *>(n); 465 DOMString type = e->getAttribute(ATTR_TYPE); 466 467 if ( strcasecmp( type, "hidden" ) == 0 && form) { 393 if (changed) 394 doc()->recalcStyle(NodeImpl::Inherit); 395 return false; 396 } 397 else if (!current->isDocumentNode()) 398 return false; 399 } else if (h->hasLocalName(HTMLNames::input())) { 400 DOMString type = h->getAttribute(ATTR_TYPE); 401 if (strcasecmp(type, "hidden") == 0 && form) { 468 402 form->addChild(n); 469 #if SPEED_DEBUG < 2 470 if(!n->attached() && HTMLWidget) 403 if (!n->attached() && HTMLWidget) 471 404 n->attach(); 472 #endif473 405 return true; 474 406 } 475 break; 476 } 477 case ID_TEXT: 478 // ignore text inside the following elements. 479 switch(current->id()) 480 { 481 case ID_SELECT: 482 return false; 483 default: 484 ; 485 // fall through!! 486 }; 487 break; 488 case ID_DD: 489 case ID_DT: 407 } else if (h->hasLocalName(HTMLNames::dd()) || h->hasLocalName(HTMLNames::dt())) { 490 408 e = new HTMLDListElementImpl(document); 491 if ( insertNode(e)) {409 if (insertNode(e)) { 492 410 insertNode(n); 493 411 return true; 494 412 } 495 break; 496 case ID_AREA: 497 { 498 if(map) 499 { 413 } else if (h->hasLocalName(HTMLNames::area())) { 414 if (map) { 500 415 map->addChild(n); 501 #if SPEED_DEBUG < 2 502 if(!n->attached() && HTMLWidget) 416 if (!n->attached() && HTMLWidget) 503 417 n->attach(); 504 #endif505 418 handled = true; 506 419 } … … 508 421 return false; 509 422 return true; 510 } 511 case ID_CAPTION: { 512 switch (current->id()) { 513 case ID_THEAD: 514 case ID_TBODY: 515 case ID_TFOOT: 516 case ID_TR: 517 case ID_TH: 518 case ID_TD: { 519 NodeImpl* tsection = current; 520 if (current->id() == ID_TR) 521 tsection = current->parent(); 522 else if (current->id() == ID_TD || current->id() == ID_TH) 523 tsection = current->parent()->parent(); 524 NodeImpl* table = tsection->parent(); 525 int exceptioncode = 0; 526 table->insertBefore(n, tsection, exceptioncode); 527 pushBlock(id, tagPriority(id)); 528 setCurrent(n); 529 inStrayTableContent++; 530 blockStack->strayTableContent = true; 531 return true; 532 } 533 default: 534 break; 535 } 536 break; 537 } 538 case ID_THEAD: 539 case ID_TBODY: 540 case ID_TFOOT: 541 case ID_COLGROUP: { 542 if (isTableRelatedTag(current->id())) { 543 while (blockStack && current->id() != ID_TABLE && isTableRelatedTag(current->id())) 423 } else if (h->hasLocalName(HTMLNames::caption())) { 424 if (isTablePart(current)) { 425 NodeImpl* tsection = current; 426 if (current->hasTagName(HTMLNames::tr())) 427 tsection = current->parent(); 428 else if (current->hasTagName(HTMLNames::td()) || current->hasTagName(HTMLNames::th())) 429 tsection = current->parent()->parent(); 430 NodeImpl* table = tsection->parent(); 431 int exceptioncode = 0; 432 table->insertBefore(n, tsection, exceptioncode); 433 pushBlock(localName, tagPriority); 434 setCurrent(n); 435 inStrayTableContent++; 436 blockStack->strayTableContent = true; 437 return true; 438 } 439 } else if (h->hasLocalName(HTMLNames::thead()) || h->hasLocalName(HTMLNames::tbody()) || 440 h->hasLocalName(HTMLNames::tfoot()) || h->hasLocalName(HTMLNames::colgroup())) { 441 if (isTableRelated(current)) { 442 while (blockStack && isTablePart(current)) 544 443 popOneBlock(); 545 444 return insertNode(n); 546 445 } 547 446 } 548 default: 549 break; 550 } 551 552 // switch on the currently active element 553 switch(current->id()) 554 { 555 case ID_HTML: 556 switch(id) 557 { 558 case ID_SCRIPT: 559 case ID_STYLE: 560 case ID_META: 561 case ID_LINK: 562 case ID_OBJECT: 563 case ID_EMBED: 564 case ID_TITLE: 565 case ID_ISINDEX: 566 case ID_BASE: 567 if(!head) { 447 } 448 449 // 2. Next we examine our currently active element to do some further error handling. 450 if (current->isHTMLElement()) { 451 HTMLElementImpl* h = static_cast<HTMLElementImpl*>(current); 452 const AtomicString& currentTagName = current->localName(); 453 if (h->hasLocalName(HTMLNames::html())) { 454 HTMLElementImpl* elt = n->isHTMLElement() ? static_cast<HTMLElementImpl*>(n) : 0; 455 if (elt && (elt->hasLocalName(HTMLNames::script()) || elt->hasLocalName(HTMLNames::style()) || 456 elt->hasLocalName(HTMLNames::meta()) || elt->hasLocalName(HTMLNames::link()) || 457 elt->hasLocalName(HTMLNames::object()) || elt->hasLocalName(HTMLNames::embed()) || 458 elt->hasLocalName(HTMLNames::title()) || elt->hasLocalName(HTMLNames::isindex()) || 459 elt->hasLocalName(HTMLNames::base()))) { 460 if (!head) { 568 461 head = new HTMLHeadElementImpl(document); 569 462 e = head; … … 571 464 handled = true; 572 465 } 573 break; 574 case ID_TEXT: { 575 TextImpl *t = static_cast<TextImpl *>(n); 576 if (t->containsOnlyWhitespace()) 577 return false; 578 /* Fall through to default */ 579 } 580 default: 581 if ( haveFrameSet ) break; 582 e = new HTMLBodyElementImpl(document); 583 startBody(); 584 insertNode(e); 585 handled = true; 586 break; 587 } 588 break; 589 case ID_HEAD: 590 // we can get here only if the element is not allowed in head. 591 if (id == ID_HTML) 466 } else { 467 if (n->isTextNode()) { 468 TextImpl *t = static_cast<TextImpl *>(n); 469 if (t->containsOnlyWhitespace()) 470 return false; 471 } 472 if (!haveFrameSet) { 473 e = new HTMLBodyElementImpl(document); 474 startBody(); 475 insertNode(e); 476 handled = true; 477 } 478 } 479 } else if (h->hasLocalName(HTMLNames::head())) { 480 if (n->hasTagName(HTMLNames::html())) 592 481 return false; 593 482 else { 594 483 // This means the body starts here... 595 if ( haveFrameSet ) break; 596 popBlock(ID_HEAD); 597 e = new HTMLBodyElementImpl(document); 598 startBody(); 599 insertNode(e); 600 handled = true; 601 } 602 break; 603 case ID_BODY: 604 break; 605 case ID_CAPTION: 484 if (!haveFrameSet) { 485 popBlock(currentTagName); 486 e = new HTMLBodyElementImpl(document); 487 startBody(); 488 insertNode(e); 489 handled = true; 490 } 491 } 492 } else if (h->hasLocalName(HTMLNames::caption())) { 606 493 // Illegal content in a caption. Close the caption and try again. 607 popBlock(ID_CAPTION); 608 switch( id ) { 609 case ID_THEAD: 610 case ID_TFOOT: 611 case ID_TBODY: 612 case ID_TR: 613 case ID_TD: 614 case ID_TH: 494 popBlock(currentTagName); 495 if (isTablePart(n)) 615 496 return insertNode(n, flat); 616 } 617 break; 618 case ID_TABLE: 619 case ID_THEAD: 620 case ID_TFOOT: 621 case ID_TBODY: 622 case ID_TR: 623 switch(id) 624 { 625 case ID_TABLE: 626 popBlock(ID_TABLE); // end the table 497 } else if (h->hasLocalName(HTMLNames::table()) || h->hasLocalName(HTMLNames::tr()) || isTableSection(h)) { 498 if (n->hasTagName(HTMLNames::table())) { 499 popBlock(localName); // end the table 627 500 handled = true; // ...and start a new one 628 break; 629 case ID_TEXT: 630 { 631 TextImpl *t = static_cast<TextImpl *>(n); 632 if (t->containsOnlyWhitespace()) 633 return false; 634 DOMStringImpl *i = t->string(); 635 unsigned int pos = 0; 636 while(pos < i->l && ( *(i->s+pos) == QChar(' ') || 637 *(i->s+pos) == QChar(0xa0))) pos++; 638 if(pos == i->l) 639 break; 640 } 641 default: 642 { 643 NodeImpl *node = current; 644 NodeImpl *parent = node->parentNode(); 645 646 NodeImpl *parentparent = parent->parentNode(); 647 648 if (n->isTextNode() || 649 ( node->id() == ID_TR && 650 ( parent->id() == ID_THEAD || 651 parent->id() == ID_TBODY || 652 parent->id() == ID_TFOOT ) && parentparent->id() == ID_TABLE ) || 653 ( !checkChild(ID_TR, id, !doc()->inCompatMode()) && ( node->id() == ID_THEAD || node->id() == ID_TBODY || node->id() == ID_TFOOT ) && 654 parent->id() == ID_TABLE )) 655 { 656 node = (node->id() == ID_TABLE) ? node : 657 ((node->id() == ID_TR) ? parentparent : parent); 501 } else { 502 bool possiblyMoveStrayContent = true; 503 int exceptionCode = 0; 504 if (n->isTextNode()) { 505 TextImpl *t = static_cast<TextImpl *>(n); 506 if (t->containsOnlyWhitespace()) 507 return false; 508 DOMStringImpl *i = t->string(); 509 unsigned int pos = 0; 510 while (pos < i->l && (*(i->s+pos) == QChar(' ') || 511 *(i->s+pos) == QChar(0xa0))) pos++; 512 if (pos == i->l) 513 possiblyMoveStrayContent = false; 514 } 515 if (possiblyMoveStrayContent) { 516 NodeImpl *node = current; 658 517 NodeImpl *parent = node->parentNode(); 659 int exceptioncode = 0; 660 parent->insertBefore( n, node, exceptioncode ); 661 if ( exceptioncode ) { 662 #ifdef PARSER_DEBUG 663 kdDebug( 6035 ) << "adding content before table failed!" << endl; 664 #endif 665 break; 518 NodeImpl *grandparent = parent->parentNode(); 519 520 if (n->isTextNode() || 521 (h->hasLocalName(HTMLNames::tr()) && 522 isTableSection(parent) && grandparent->hasTagName(HTMLNames::table())) || 523 ((!n->hasTagName(HTMLNames::td()) && !n->hasTagName(HTMLNames::th()) && 524 !n->hasTagName(HTMLNames::form()) && !n->hasTagName(HTMLNames::script())) && isTableSection(node) && 525 parent->hasTagName(HTMLNames::table()))) { 526 node = (node->hasTagName(HTMLNames::table())) ? node : 527 ((node->hasTagName(HTMLNames::tr())) ? grandparent : parent); 528 NodeImpl *parent = node->parentNode(); 529 parent->insertBefore(n, node, exceptionCode); 530 if (!exceptionCode) { 531 if (n->isHTMLElement() && tagPriority > 0 && 532 !flat && static_cast<HTMLElementImpl*>(n)->endTagRequirement() != TagStatusForbidden) 533 { 534 pushBlock(localName, tagPriority); 535 setCurrent(n); 536 inStrayTableContent++; 537 blockStack->strayTableContent = true; 538 } 539 return true; 540 } 666 541 } 667 if (n->isElementNode() && tagPriority(id) != 0 && 668 !flat && endTagRequirement(id) != DOM::FORBIDDEN) 669 { 670 pushBlock(id, tagPriority(id)); 671 setCurrent(n); 672 inStrayTableContent++; 673 blockStack->strayTableContent = true; 542 543 if (!exceptionCode) { 544 if (current->hasTagName(HTMLNames::tr())) 545 e = new HTMLTableCellElementImpl(HTMLNames::td(), document); 546 else if (current->hasTagName(HTMLNames::table())) 547 e = new HTMLTableSectionElementImpl(HTMLNames::tbody(), document, true); // implicit 548 else 549 e = new HTMLTableRowElementImpl(document); 550 551 insertNode(e); 552 handled = true; 674 553 } 675 return true;676 554 } 677 678 if ( current->id() == ID_TR ) 679 e = new HTMLTableCellElementImpl(document, ID_TD); 680 else if ( current->id() == ID_TABLE ) 681 e = new HTMLTableSectionElementImpl( document, ID_TBODY, true /* implicit */ ); 682 else 683 e = new HTMLTableRowElementImpl( document ); 684 685 insertNode(e); 686 handled = true; 687 break; 688 } // end default 689 } // end switch 690 break; 691 case ID_OBJECT: 692 discard_until = ID_OBJECT + ID_CLOSE_TAG; 555 } 556 } 557 else if (h->hasLocalName(HTMLNames::object())) { 558 setSkipMode(HTMLNames::object()); 693 559 return false; 694 case ID_UL: 695 case ID_OL: 696 case ID_DIR: 697 case ID_MENU: 560 } else if (h->hasLocalName(HTMLNames::ul()) || h->hasLocalName(HTMLNames::ol()) || 561 h->hasLocalName(HTMLNames::dir()) || h->hasLocalName(HTMLNames::menu())) { 698 562 e = new HTMLDivElementImpl(document); 699 563 insertNode(e); 700 564 handled = true; 701 break; 702 case ID_DL: 703 popBlock(ID_DL); 565 } else if (h->hasLocalName(HTMLNames::dl()) || h->hasLocalName(HTMLNames::dt())) { 566 popBlock(currentTagName); 567 handled = true; 568 } else if (h->hasLocalName(HTMLNames::select())) { 569 if (isInline(n)) 570 return false; 571 } else if (h->hasLocalName(HTMLNames::p()) || isHeaderTag(currentTagName)) { 572 if (!isInline(n)) { 573 popBlock(currentTagName); 704 574 handled = true; 705 break; 706 case ID_DT: 707 popBlock(ID_DT); 575 } 576 } else if (h->hasLocalName(HTMLNames::option()) || h->hasLocalName(HTMLNames::optgroup())) { 577 if (localName == HTMLNames::optgroup()) { 578 popBlock(currentTagName); 708 579 handled = true; 709 break; 710 case ID_SELECT: 711 if( n->isInline() ) 712 return false; 713 break; 714 case ID_P: 715 case ID_H1: 716 case ID_H2: 717 case ID_H3: 718 case ID_H4: 719 case ID_H5: 720 case ID_H6: 721 if(!n->isInline()) 722 { 723 popBlock(current->id()); 580 } 581 else if (localName == HTMLNames::select()) { 582 // IE treats a nested select as </select>. Let's do the same 583 popBlock(localName); 584 } 585 } else if (h->hasLocalName(HTMLNames::address())) { 586 popBlock(currentTagName); 587 handled = true; 588 } else if (h->hasLocalName(HTMLNames::colgroup())) { 589 if (!n->isTextNode()) { 590 popBlock(currentTagName); 724 591 handled = true; 725 592 } 726 break; 727 case ID_OPTION: 728 case ID_OPTGROUP: 729 if (id == ID_OPTGROUP) 730 { 731 popBlock(current->id()); 732 handled = true; 733 } 734 else if(id == ID_SELECT) 735 { 736 // IE treats a nested select as </select>. Let's do the same 737 popBlock( ID_SELECT ); 738 break; 739 } 740 break; 741 // head elements in the body should be ignored. 742 case ID_ADDRESS: 743 popBlock(ID_ADDRESS); 593 } else if (h->hasLocalName(HTMLNames::font())) { 594 popBlock(currentTagName); 744 595 handled = true; 745 break; 746 case ID_COLGROUP: 747 if (id != ID_TEXT) { 748 popBlock(ID_COLGROUP); 749 handled = true; 750 } 751 break; 752 case ID_FONT: 753 popBlock(ID_FONT); 754 handled = true; 755 break; 756 default: 757 if(current->isDocumentNode()) 758 { 759 if(current->firstChild() == 0) { 760 e = new HTMLHtmlElementImpl(document); 761 insertNode(e); 762 handled = true; 763 } 764 } 765 else if(current->isInline()) 766 { 596 } else if (!h->hasLocalName(HTMLNames::body())) { 597 if (isInline(current)) { 767 598 popInlineBlocks(); 768 599 handled = true; 769 600 } 770 601 } 771 772 // if we couldn't handle the error, just rethrow the exception... 773 if(!handled) 774 { 775 //kdDebug( 6035 ) << "Exception handler failed in HTMLPArser::insertNode()" << endl; 776 return false; 777 } 778 779 return insertNode(n); 780 } 781 } 782 783 NodeImpl *KHTMLParser::getElement(Token* t) 784 { 785 switch (t->id) 786 { 787 case ID_HEAD: 788 if (!head && current->id() == ID_HTML) { 789 head = new HTMLHeadElementImpl(document); 790 return head; 791 } 792 return 0; 793 case ID_BODY: 794 // body no longer allowed if we have a frameset 795 if (haveFrameSet) 796 return 0; 797 popBlock(ID_HEAD); 798 startBody(); 799 return new HTMLBodyElementImpl(document); 800 801 // frames 802 case ID_FRAMESET: 803 popBlock(ID_HEAD); 804 if (inBody && !haveFrameSet && !haveContent) { 805 popBlock(ID_BODY); 806 // ### actually for IE document.body returns the now hidden "body" element 807 // we can't implement that behaviour now because it could cause too many 808 // regressions and the headaches are not worth the work as long as there is 809 // no site actually relying on that detail (Dirk) 810 if (doc()->body()) 811 doc()->body()->setAttribute(ATTR_STYLE, "display:none"); 812 inBody = false; 813 } 814 if ((haveContent || haveFrameSet) && current->id() == ID_HTML) 815 return 0; 816 haveFrameSet = true; 817 startBody(); 818 return new HTMLFrameSetElementImpl(document); 819 602 } 603 else if (current->isDocumentNode()) { 604 if (current->firstChild() == 0) { 605 e = new HTMLHtmlElementImpl(document); 606 insertNode(e); 607 handled = true; 608 } 609 } 610 611 // 3. If we couldn't handle the error, just return false and attempt to error-correct again. 612 if (!handled) 613 return false; 614 return insertNode(n); 615 } 616 617 typedef bool (HTMLParser::*CreateErrorCheckFunc)(Token* t, NodeImpl*&); 618 typedef HashMap<DOMStringImpl *, CreateErrorCheckFunc, PointerHash<DOMStringImpl *> > FunctionMap; 619 620 bool HTMLParser::textCreateErrorCheck(Token* t, NodeImpl*& result) 621 { 622 result = new TextImpl(document, t->text); 623 return false; 624 } 625 626 bool HTMLParser::commentCreateErrorCheck(Token* t, NodeImpl*& result) 627 { 628 if (includesCommentsInDOM) 629 result = new CommentImpl(document, t->text); 630 return false; 631 } 632 633 bool HTMLParser::headCreateErrorCheck(Token* t, NodeImpl*& result) 634 { 635 return (!head || current->localName() == HTMLNames::html()); 636 } 637 638 bool HTMLParser::bodyCreateErrorCheck(Token* t, NodeImpl*& result) 639 { 640 // body no longer allowed if we have a frameset 641 if (haveFrameSet) 642 return false; 643 popBlock(HTMLNames::head()); 644 startBody(); 645 return true; 646 } 647 648 bool HTMLParser::framesetCreateErrorCheck(Token* t, NodeImpl*& result) 649 { 650 popBlock(HTMLNames::head()); 651 if (inBody && !haveFrameSet && !haveContent) { 652 popBlock(HTMLNames::body()); 653 // ### actually for IE document.body returns the now hidden "body" element 654 // we can't implement that behaviour now because it could cause too many 655 // regressions and the headaches are not worth the work as long as there is 656 // no site actually relying on that detail (Dirk) 657 if (doc()->body()) 658 doc()->body()->setAttribute(ATTR_STYLE, "display:none"); 659 inBody = false; 660 } 661 if ((haveContent || haveFrameSet) && current->localName() == HTMLNames::html()) 662 return false; 663 haveFrameSet = true; 664 startBody(); 665 return true; 666 } 667 668 bool HTMLParser::iframeCreateErrorCheck(Token* t, NodeImpl*& result) 669 { 820 670 // a bit of a special case, since the frame is inlined 821 case ID_IFRAME: 822 discard_until = ID_IFRAME + ID_CLOSE_TAG; 823 break; 824 825 // form elements 826 case ID_FORM: 827 // Only create a new form if we're not already inside one. 828 // This is consistent with other browsers' behavior. 829 if (form) 830 return 0; 831 form = new HTMLFormElementImpl(document); 832 return form; 833 case ID_BUTTON: 834 return new HTMLButtonElementImpl(document, form); 835 case ID_FIELDSET: 836 return new HTMLFieldSetElementImpl(document, form); 837 case ID_INPUT: 838 return new HTMLInputElementImpl(document, form); 839 case ID_ISINDEX: { 840 NodeImpl *n = handleIsindex(t); 841 if (!inBody) { 842 if (isindex) 843 isindex->deref(); 844 isindex = n; 845 isindex->ref(); 846 return 0; 847 } 671 setSkipMode(HTMLNames::iframe()); 672 return true; 673 } 674 675 bool HTMLParser::formCreateErrorCheck(Token* t, NodeImpl*& result) 676 { 677 // Only create a new form if we're not already inside one. 678 // This is consistent with other browsers' behavior. 679 return !form; 680 } 681 682 bool HTMLParser::isindexCreateErrorCheck(Token* t, NodeImpl*& result) 683 { 684 NodeImpl *n = handleIsindex(t); 685 if (!inBody) { 686 if (isindex) 687 isindex->deref(); 688 isindex = n; 689 isindex->ref(); 690 } else { 848 691 t->flat = true; 849 return n; 850 } 851 case ID_KEYGEN: 852 return new HTMLKeygenElementImpl(document, form); 853 case ID_LEGEND: 854 return new HTMLLegendElementImpl(document, form); 855 case ID_OPTGROUP: 856 return new HTMLOptGroupElementImpl(document, form); 857 case ID_OPTION: 858 return new HTMLOptionElementImpl(document, form); 859 case ID_SELECT: 860 inSelect = true; 861 return new HTMLSelectElementImpl(document, form); 862 case ID_TEXTAREA: 863 return new HTMLTextAreaElementImpl(document, form); 864 865 // lists 866 case ID_DD: 867 popBlock(ID_DT); 868 popBlock(ID_DD); 869 break; 870 case ID_DT: 871 popBlock(ID_DD); 872 popBlock(ID_DT); 873 break; 874 case ID_LI: 875 popBlock(ID_LI); 876 break; 877 878 // anchor 879 case ID_A: 880 // Never allow nested <a>s. 881 popBlock(ID_A); 882 break; 883 884 // images 885 case ID_IMG: 886 return new HTMLImageElementImpl(document, form); 887 case ID_MAP: 888 map = new HTMLMapElementImpl(document); 889 return map; 890 891 // tables 892 case ID_TR: 893 popBlock(ID_TR); 894 break; 895 case ID_TD: 896 case ID_TH: 897 popBlock(ID_TH); 898 popBlock(ID_TD); 899 break; 900 case ID_TBODY: 901 case ID_THEAD: 902 case ID_TFOOT: 903 popBlock(ID_THEAD); 904 popBlock(ID_TBODY); 905 popBlock(ID_TFOOT); 906 break; 907 908 // elements with no special representation in the DOM 909 case ID_TT: 910 case ID_U: 911 case ID_B: 912 case ID_I: 913 case ID_S: 914 case ID_STRIKE: 915 case ID_BIG: 916 case ID_SMALL: 917 if (!allowNestedRedundantTag(t->id)) 918 return 0; 919 break; 920 921 case ID_NOBR: 922 case ID_WBR: 923 popBlock(t->id); // Don't allow nested <nobr> or <wbr> 924 break; 925 926 // these are special, and normally not rendered 927 case ID_NOEMBED: 928 discard_until = ID_NOEMBED + ID_CLOSE_TAG; 929 return 0; 930 case ID_NOFRAMES: 931 discard_until = ID_NOFRAMES + ID_CLOSE_TAG; 932 return 0; 933 case ID_NOSCRIPT: 934 if (HTMLWidget && HTMLWidget->part()->jScriptEnabled()) 935 discard_until = ID_NOSCRIPT + ID_CLOSE_TAG; 936 return 0; 937 case ID_NOLAYER: 938 //discard_until = ID_NOLAYER + ID_CLOSE_TAG; 939 return 0; 940 case ID_TEXT: 941 return new TextImpl(document, t->text); 942 case ID_COMMENT: 943 if (!includesCommentsInDOM) 944 return 0; 945 break; 946 947 case ID_SCRIPT: 948 { 949 HTMLScriptElementImpl *scriptElement = new HTMLScriptElementImpl(document); 950 scriptElement->setCreatedByParser(true); 951 return scriptElement; 952 } 953 } 954 955 return document->document()->createHTMLElement(t->id); 692 result = n; 693 } 694 return false; 695 } 696 697 bool HTMLParser::selectCreateErrorCheck(Token* t, NodeImpl*& result) 698 { 699 inSelect = true; 700 return true; 701 } 702 703 bool HTMLParser::ddCreateErrorCheck(Token* t, NodeImpl*& result) 704 { 705 popBlock(HTMLNames::dt()); 706 popBlock(HTMLNames::dd()); 707 return true; 708 } 709 710 bool HTMLParser::dtCreateErrorCheck(Token* t, NodeImpl*& result) 711 { 712 popBlock(HTMLNames::dd()); 713 popBlock(HTMLNames::dt()); 714 return true; 715 } 716 717 bool HTMLParser::nestedCreateErrorCheck(Token* t, NodeImpl*& result) 718 { 719 popBlock(t->tagName); 720 return true; 721 } 722 723 bool HTMLParser::nestedStyleCreateErrorCheck(Token* t, NodeImpl*& result) 724 { 725 return allowNestedRedundantTag(t->tagName); 726 } 727 728 bool HTMLParser::tableCellCreateErrorCheck(Token* t, NodeImpl*& result) 729 { 730 popBlock(HTMLNames::td()); 731 popBlock(HTMLNames::th()); 732 return true; 733 } 734 735 bool HTMLParser::tableSectionCreateErrorCheck(Token* t, NodeImpl*& result) 736 { 737 popBlock(HTMLNames::thead()); 738 popBlock(HTMLNames::tbody()); 739 popBlock(HTMLNames::tfoot()); 740 return true; 741 } 742 743 bool HTMLParser::noembedCreateErrorCheck(Token* t, NodeImpl*& result) 744 { 745 setSkipMode(HTMLNames::noembed()); 746 return false; 747 } 748 749 bool HTMLParser::noframesCreateErrorCheck(Token* t, NodeImpl*& result) 750 { 751 setSkipMode(HTMLNames::noframes()); 752 return false; 753 } 754 755 bool HTMLParser::noscriptCreateErrorCheck(Token* t, NodeImpl*& result) 756 { 757 if (HTMLWidget && HTMLWidget->part()->jScriptEnabled()) 758 setSkipMode(HTMLNames::noscript()); 759 return false; 760 } 761 762 bool HTMLParser::nolayerCreateErrorCheck(Token* t, NodeImpl*& result) 763 { 764 return false; 765 } 766 767 NodeImpl *HTMLParser::getNode(Token* t) 768 { 769 // Init our error handling table. 770 static FunctionMap gFunctionMap; 771 if (gFunctionMap.isEmpty()) { 772 gFunctionMap.insert(textAtom.implementation(), &HTMLParser::textCreateErrorCheck); 773 gFunctionMap.insert(commentAtom.implementation(), &HTMLParser::commentCreateErrorCheck); 774 gFunctionMap.insert(HTMLNames::head().localName().implementation(), &HTMLParser::headCreateErrorCheck); 775 gFunctionMap.insert(HTMLNames::body().localName().implementation(), &HTMLParser::bodyCreateErrorCheck); 776 gFunctionMap.insert(HTMLNames::frameset().localName().implementation(), &HTMLParser::framesetCreateErrorCheck); 777 gFunctionMap.insert(HTMLNames::iframe().localName().implementation(), &HTMLParser::iframeCreateErrorCheck); 778 gFunctionMap.insert(HTMLNames::form().localName().implementation(), &HTMLParser::formCreateErrorCheck); 779 gFunctionMap.insert(HTMLNames::isindex().localName().implementation(), &HTMLParser::isindexCreateErrorCheck); 780 gFunctionMap.insert(HTMLNames::select().localName().implementation(), &HTMLParser::selectCreateErrorCheck); 781 gFunctionMap.insert(HTMLNames::dd().localName().implementation(), &HTMLParser::ddCreateErrorCheck); 782 gFunctionMap.insert(HTMLNames::dt().localName().implementation(), &HTMLParser::dtCreateErrorCheck); 783 gFunctionMap.insert(HTMLNames::li().localName().implementation(), &HTMLParser::nestedCreateErrorCheck); 784 gFunctionMap.insert(HTMLNames::a().localName().implementation(), &HTMLParser::nestedCreateErrorCheck); 785 gFunctionMap.insert(HTMLNames::nobr().localName().implementation(), &HTMLParser::nestedCreateErrorCheck); 786 gFunctionMap.insert(HTMLNames::wbr().localName().implementation(), &HTMLParser::nestedCreateErrorCheck); 787 gFunctionMap.insert(HTMLNames::tr().localName().implementation(), &HTMLParser::nestedCreateErrorCheck); 788 gFunctionMap.insert(HTMLNames::td().localName().implementation(), &HTMLParser::tableCellCreateErrorCheck); 789 gFunctionMap.insert(HTMLNames::th().localName().implementation(), &HTMLParser::tableCellCreateErrorCheck); 790 gFunctionMap.insert(HTMLNames::tbody().localName().implementation(), &HTMLParser::tableSectionCreateErrorCheck); 791 gFunctionMap.insert(HTMLNames::thead().localName().implementation(), &HTMLParser::tableSectionCreateErrorCheck); 792 gFunctionMap.insert(HTMLNames::tfoot().localName().implementation(), &HTMLParser::tableSectionCreateErrorCheck); 793 gFunctionMap.insert(HTMLNames::tt().localName().implementation(), &HTMLParser::nestedStyleCreateErrorCheck); 794 gFunctionMap.insert(HTMLNames::u().localName().implementation(), &HTMLParser::nestedStyleCreateErrorCheck); 795 gFunctionMap.insert(HTMLNames::b().localName().implementation(), &HTMLParser::nestedStyleCreateErrorCheck); 796 gFunctionMap.insert(HTMLNames::i().localName().implementation(), &HTMLParser::nestedStyleCreateErrorCheck); 797 gFunctionMap.insert(HTMLNames::s().localName().implementation(), &HTMLParser::nestedStyleCreateErrorCheck); 798 gFunctionMap.insert(HTMLNames::strike().localName().implementation(), &HTMLParser::nestedStyleCreateErrorCheck); 799 gFunctionMap.insert(HTMLNames::big().localName().implementation(), &HTMLParser::nestedStyleCreateErrorCheck); 800 gFunctionMap.insert(HTMLNames::small().localName().implementation(), &HTMLParser::nestedStyleCreateErrorCheck); 801 gFunctionMap.insert(HTMLNames::noembed().localName().implementation(), &HTMLParser::noembedCreateErrorCheck); 802 gFunctionMap.insert(HTMLNames::noframes().localName().implementation(), &HTMLParser::noframesCreateErrorCheck); 803 gFunctionMap.insert(HTMLNames::noscript().localName().implementation(), &HTMLParser::noscriptCreateErrorCheck); 804 gFunctionMap.insert(HTMLNames::nolayer().localName().implementation(), &HTMLParser::nolayerCreateErrorCheck); 805 } 806 807 bool proceed = true; 808 NodeImpl* result = 0; 809 CreateErrorCheckFunc errorCheckFunc = gFunctionMap.get(t->tagName.implementation()); 810 if (errorCheckFunc) 811 proceed = (this->*(errorCheckFunc))(t, result); 812 813 if (proceed) { 814 result = HTMLElementFactory::createHTMLElement(t->tagName, doc(), form); 815 if (t->tagName == HTMLNames::form()) 816 form = static_cast<HTMLFormElementImpl*>(result); 817 } 818 return result; 956 819 } 957 820 958 821 #define MAX_REDUNDANT 20 959 822 960 bool KHTMLParser::allowNestedRedundantTag(int _id)823 bool HTMLParser::allowNestedRedundantTag(const AtomicString& _tagName) 961 824 { 962 825 // www.liceo.edu.mx is an example of a site that achieves a level of nesting of … … 965 828 int i = 0; 966 829 for (HTMLStackElem* curr = blockStack; 967 i < MAX_REDUNDANT && curr && curr-> id == _id;830 i < MAX_REDUNDANT && curr && curr->tagName == _tagName; 968 831 curr = curr->next, i++); 969 832 return i != MAX_REDUNDANT; 970 833 } 971 834 972 void KHTMLParser::processCloseTag(Token *t) 973 { 974 // support for really broken html. Can't believe I'm supporting such crap (lars) 975 switch(t->id) 976 { 977 case ID_HTML+ID_CLOSE_TAG: 978 case ID_BODY+ID_CLOSE_TAG: 979 // we never close the body tag, since some stupid web pages close it before the actual end of the doc. 980 // let's rely on the end() call to close things. 835 void HTMLParser::processCloseTag(Token *t) 836 { 837 // Support for really broken html. 838 // we never close the body tag, since some stupid web pages close it before the actual end of the doc. 839 // let's rely on the end() call to close things. 840 if (t->tagName == HTMLNames::html() || t->tagName == HTMLNames::body()) 981 841 return; 982 case ID_FORM+ID_CLOSE_TAG: 842 843 if (t->tagName == HTMLNames::form()) 983 844 form = 0; 984 // this one is to get the right style on the body element 985 break; 986 case ID_MAP+ID_CLOSE_TAG: 845 else if (t->tagName == HTMLNames::map()) 987 846 map = 0; 988 break; 989 case ID_SELECT+ID_CLOSE_TAG: 847 else if (t->tagName == HTMLNames::select()) 990 848 inSelect = false; 991 break; 992 default: 993 break; 994 } 995 996 #ifdef PARSER_DEBUG 997 kdDebug( 6035 ) << "added the following childs to " << current->nodeName().string() << endl; 998 NodeImpl *child = current->firstChild(); 999 while(child != 0) 1000 { 1001 kdDebug( 6035 ) << " " << child->nodeName().string() << endl; 1002 child = child->nextSibling(); 1003 } 1004 #endif 849 1005 850 HTMLStackElem* oldElem = blockStack; 1006 popBlock(t-> id-ID_CLOSE_TAG);1007 if (oldElem == blockStack && t-> id == ID_P+ID_CLOSE_TAG) {851 popBlock(t->tagName); 852 if (oldElem == blockStack && t->tagName == HTMLNames::p()) { 1008 853 // We encountered a stray </p>. Amazingly Gecko, WinIE, and MacIE all treat 1009 854 // this as a valid break, i.e., <p></p>. So go ahead and make the empty 1010 855 // paragraph. 1011 t-> id-=ID_CLOSE_TAG;856 t->beginTag = true; 1012 857 parseToken(t); 1013 popBlock( ID_P);858 popBlock(t->tagName); 1014 859 } 1015 860 #ifdef PARSER_DEBUG … … 1018 863 } 1019 864 1020 bool KHTMLParser::isHeaderTag(int _id)1021 { 1022 s witch (_id) {1023 case ID_H1:1024 case ID_H2:1025 case ID_H3:1026 case ID_H4:1027 case ID_H5:1028 case ID_H6:1029 return true;1030 default:1031 return false;1032 }1033 } 1034 1035 void KHTMLParser::popNestedHeaderTag()865 bool HTMLParser::isHeaderTag(const AtomicString& tagName) 866 { 867 static HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > headerTags; 868 if (headerTags.isEmpty()) { 869 headerTags.insert(HTMLNames::h1().localName().implementation()); 870 headerTags.insert(HTMLNames::h2().localName().implementation()); 871 headerTags.insert(HTMLNames::h3().localName().implementation()); 872 headerTags.insert(HTMLNames::h4().localName().implementation()); 873 headerTags.insert(HTMLNames::h5().localName().implementation()); 874 headerTags.insert(HTMLNames::h6().localName().implementation()); 875 } 876 877 return headerTags.contains(tagName.implementation()); 878 } 879 880 void HTMLParser::popNestedHeaderTag() 1036 881 { 1037 882 // This function only cares about checking for nested headers that have only inlines in between them. 1038 883 NodeImpl* currNode = current; 1039 884 for (HTMLStackElem* curr = blockStack; curr; curr = curr->next) { 1040 if (isHeaderTag(curr-> id)) {1041 popBlock(curr-> id);885 if (isHeaderTag(curr->tagName)) { 886 popBlock(curr->tagName); 1042 887 return; 1043 888 } 1044 if (currNode && ! currNode->isInline())889 if (currNode && !isInline(currNode)) 1045 890 return; 1046 891 currNode = curr->node; … … 1048 893 } 1049 894 1050 bool KHTMLParser::isResidualStyleTag(int _id) 1051 { 1052 switch (_id) { 1053 case ID_A: 1054 case ID_FONT: 1055 case ID_TT: 1056 case ID_U: 1057 case ID_B: 1058 case ID_I: 1059 case ID_S: 1060 case ID_STRIKE: 1061 case ID_BIG: 1062 case ID_SMALL: 1063 case ID_EM: 1064 case ID_STRONG: 1065 case ID_DFN: 1066 case ID_CODE: 1067 case ID_SAMP: 1068 case ID_KBD: 1069 case ID_VAR: 895 bool HTMLParser::isInline(DOM::NodeImpl* node) const 896 { 897 if (node->isTextNode()) 898 return true; 899 900 if (node->isHTMLElement()) { 901 HTMLElementImpl* e = static_cast<HTMLElementImpl*>(node); 902 if (e->hasLocalName(HTMLNames::a()) || e->hasLocalName(HTMLNames::font()) || e->hasLocalName(HTMLNames::tt()) || 903 e->hasLocalName(HTMLNames::u()) || e->hasLocalName(HTMLNames::b()) || e->hasLocalName(HTMLNames::i()) || 904 e->hasLocalName(HTMLNames::s()) || e->hasLocalName(HTMLNames::strike()) || e->hasLocalName(HTMLNames::big()) || 905 e->hasLocalName(HTMLNames::small()) || e->hasLocalName(HTMLNames::em()) || e->hasLocalName(HTMLNames::strong()) || 906 e->hasLocalName(HTMLNames::dfn()) || e->hasLocalName(HTMLNames::code()) || e->hasLocalName(HTMLNames::samp()) || 907 e->hasLocalName(HTMLNames::kbd()) || e->hasLocalName(HTMLNames::var()) || e->hasLocalName(HTMLNames::cite()) || 908 e->hasLocalName(HTMLNames::abbr()) || e->hasLocalName(HTMLNames::acronym()) || e->hasLocalName(HTMLNames::sub()) || 909 e->hasLocalName(HTMLNames::sup()) || e->hasLocalName(HTMLNames::span()) || e->hasLocalName(HTMLNames::nobr()) || 910 e->hasLocalName(HTMLNames::wbr())) 1070 911 return true; 1071 default: 1072 return false; 1073 } 1074 } 1075 1076 bool KHTMLParser::isAffectedByResidualStyle(int _id) 1077 { 1078 if (isResidualStyleTag(_id)) 912 } 913 914 return false; 915 } 916 917 bool HTMLParser::isResidualStyleTag(const AtomicString& tagName) 918 { 919 static HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > residualStyleTags; 920 if (residualStyleTags.isEmpty()) { 921 residualStyleTags.insert(HTMLNames::a().localName().implementation()); 922 residualStyleTags.insert(HTMLNames::font().localName().implementation()); 923 residualStyleTags.insert(HTMLNames::tt().localName().implementation()); 924 residualStyleTags.insert(HTMLNames::u().localName().implementation()); 925 residualStyleTags.insert(HTMLNames::b().localName().implementation()); 926 residualStyleTags.insert(HTMLNames::i().localName().implementation()); 927 residualStyleTags.insert(HTMLNames::s().localName().implementation()); 928 residualStyleTags.insert(HTMLNames::strike().localName().implementation()); 929 residualStyleTags.insert(HTMLNames::big().localName().implementation()); 930 residualStyleTags.insert(HTMLNames::small().localName().implementation()); 931 residualStyleTags.insert(HTMLNames::em().localName().implementation()); 932 residualStyleTags.insert(HTMLNames::strong().localName().implementation()); 933 residualStyleTags.insert(HTMLNames::dfn().localName().implementation()); 934 residualStyleTags.insert(HTMLNames::code().localName().implementation()); 935 residualStyleTags.insert(HTMLNames::samp().localName().implementation()); 936 residualStyleTags.insert(HTMLNames::kbd().localName().implementation()); 937 residualStyleTags.insert(HTMLNames::var().localName().implementation()); 938 } 939 940 return residualStyleTags.contains(tagName.implementation()); 941 } 942 943 bool HTMLParser::isAffectedByResidualStyle(const AtomicString& tagName) 944 { 945 if (isResidualStyleTag(tagName)) 1079 946 return true; 1080 1081 s witch (_id) {1082 case ID_P:1083 case ID_DIV:1084 case ID_BLOCKQUOTE:1085 case ID_ADDRESS:1086 case ID_H1:1087 case ID_H2:1088 case ID_H3:1089 case ID_H4:1090 case ID_H5:1091 case ID_H6:1092 case ID_CENTER:1093 case ID_UL:1094 case ID_OL:1095 case ID_LI:1096 case ID_DL:1097 case ID_DT:1098 case ID_DD:1099 case ID_PRE:1100 return true;1101 default:1102 return false;1103 }1104 } 1105 1106 void KHTMLParser::handleResidualStyleCloseTagAcrossBlocks(HTMLStackElem* elem)947 948 static HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > affectedBlockTags; 949 if (affectedBlockTags.isEmpty()) { 950 affectedBlockTags.insert(HTMLNames::h1().localName().implementation()); 951 affectedBlockTags.insert(HTMLNames::h2().localName().implementation()); 952 affectedBlockTags.insert(HTMLNames::h3().localName().implementation()); 953 affectedBlockTags.insert(HTMLNames::h4().localName().implementation()); 954 affectedBlockTags.insert(HTMLNames::h5().localName().implementation()); 955 affectedBlockTags.insert(HTMLNames::h6().localName().implementation()); 956 affectedBlockTags.insert(HTMLNames::p().localName().implementation()); 957 affectedBlockTags.insert(HTMLNames::div().localName().implementation()); 958 affectedBlockTags.insert(HTMLNames::blockquote().localName().implementation()); 959 affectedBlockTags.insert(HTMLNames::address().localName().implementation()); 960 affectedBlockTags.insert(HTMLNames::center().localName().implementation()); 961 affectedBlockTags.insert(HTMLNames::ul().localName().implementation()); 962 affectedBlockTags.insert(HTMLNames::ol().localName().implementation()); 963 affectedBlockTags.insert(HTMLNames::li().localName().implementation()); 964 affectedBlockTags.insert(HTMLNames::dl().localName().implementation()); 965 affectedBlockTags.insert(HTMLNames::dt().localName().implementation()); 966 affectedBlockTags.insert(HTMLNames::dd().localName().implementation()); 967 affectedBlockTags.insert(HTMLNames::pre().localName().implementation()); 968 } 969 970 return affectedBlockTags.contains(tagName.implementation()); 971 } 972 973 void HTMLParser::handleResidualStyleCloseTagAcrossBlocks(HTMLStackElem* elem) 1107 974 { 1108 975 // Find the element that crosses over to a higher level. For now, if there is more than … … 1126 993 } 1127 994 1128 if (!curr || !maxElem || !isAffectedByResidualStyle(maxElem-> id)) return;995 if (!curr || !maxElem || !isAffectedByResidualStyle(maxElem->tagName)) return; 1129 996 1130 997 NodeImpl* residualElem = prev->node; … … 1148 1015 while (currElem != elem) { 1149 1016 HTMLStackElem* nextElem = currElem->next; 1150 if (!isResidualStyleTag(currElem-> id)) {1017 if (!isResidualStyleTag(currElem->tagName)) { 1151 1018 prevElem->next = nextElem; 1152 1019 prevElem->node = currElem->node; … … 1170 1037 currElem = maxElem; 1171 1038 while (currElem->node != residualElem) { 1172 if (isResidualStyleTag(currElem->node-> id())) {1039 if (isResidualStyleTag(currElem->node->localName())) { 1173 1040 // Create a clone of this element. 1174 1041 currNode = currElem->node->cloneNode(false); … … 1246 1113 // after we complete the close of this entire block. 1247 1114 NodeImpl* currNode = current; 1248 if (isResidualStyleTag(curr-> id)) {1115 if (isResidualStyleTag(curr->tagName)) { 1249 1116 // We've overloaded the use of stack elements and are just reusing the 1250 1117 // struct with a slightly different meaning to the variables. Instead of chaining … … 1270 1137 } 1271 1138 1272 void KHTMLParser::reopenResidualStyleTags(HTMLStackElem* elem, DOM::NodeImpl* malformedTableParent)1139 void HTMLParser::reopenResidualStyleTags(HTMLStackElem* elem, DOM::NodeImpl* malformedTableParent) 1273 1140 { 1274 1141 // Loop for each tag that needs to be reopened. … … 1287 1154 1288 1155 // Now push a new stack element for this node we just created. 1289 pushBlock(elem-> id, elem->level);1156 pushBlock(elem->tagName, elem->level); 1290 1157 1291 1158 // Set our strayTableContent boolean if needed, so that the reopened tag also knows … … 1308 1175 } 1309 1176 1310 void KHTMLParser::pushBlock(int _id, int _level) 1311 { 1312 HTMLStackElem *Elem = new HTMLStackElem(_id, _level, current, blockStack); 1313 1177 void HTMLParser::pushBlock(const AtomicString& tagName, int _level) 1178 { 1179 HTMLStackElem *Elem = new HTMLStackElem(tagName, _level, current, blockStack); 1314 1180 blockStack = Elem; 1315 addForbidden(_id, forbiddenTag); 1316 } 1317 1318 void KHTMLParser::popBlock( int _id ) 1181 } 1182 1183 void HTMLParser::popBlock(const AtomicString& _tagName) 1319 1184 { 1320 1185 HTMLStackElem *Elem = blockStack; … … 1322 1187 int maxLevel = 0; 1323 1188 1324 #ifdef PARSER_DEBUG 1325 kdDebug( 6035 ) << "popBlock(" << getTagName(_id).string() << ")" << endl; 1326 while(Elem) { 1327 kdDebug( 6035) << " > " << getTagName(Elem->id).string() << endl; 1328 Elem = Elem->next; 1329 } 1330 Elem = blockStack; 1331 #endif 1332 1333 while( Elem && (Elem->id != _id)) 1334 { 1189 while (Elem && (Elem->tagName != _tagName)) { 1335 1190 if (maxLevel < Elem->level) 1336 {1337 1191 maxLevel = Elem->level; 1338 }1339 1192 Elem = Elem->next; 1340 1193 } … … 1346 1199 // We didn't match because the tag is in a different scope, e.g., 1347 1200 // <b><p>Foo</b>. Try to correct the problem. 1348 if (!isResidualStyleTag(_ id))1201 if (!isResidualStyleTag(_tagName)) 1349 1202 return; 1350 1203 return handleResidualStyleCloseTagAcrossBlocks(Elem); 1351 1204 } 1352 1205 1353 bool isAffectedByStyle = isAffectedByResidualStyle(Elem-> id);1206 bool isAffectedByStyle = isAffectedByResidualStyle(Elem->tagName); 1354 1207 HTMLStackElem* residualStyleStack = 0; 1355 1208 NodeImpl* malformedTableParent = 0; 1356 1209 1357 1210 Elem = blockStack; 1358 while (Elem) 1359 { 1360 if (Elem->id == _id) 1361 { 1211 while (Elem) { 1212 if (Elem->tagName == _tagName) { 1362 1213 int strayTable = inStrayTableContent; 1363 1214 popOneBlock(); … … 1370 1221 if (strayTable && (inStrayTableContent < strayTable) && residualStyleStack) { 1371 1222 NodeImpl* curr = current; 1372 while (curr && curr->id() != ID_TABLE)1223 while (curr && !curr->hasTagName(HTMLNames::table())) 1373 1224 curr = curr->parentNode(); 1374 1225 malformedTableParent = curr ? curr->parentNode() : 0; 1375 1226 } 1376 1227 } 1377 else 1378 { 1379 if (Elem->id == ID_FORM && form) 1228 else { 1229 if (form && Elem->tagName == HTMLNames::form()) 1380 1230 // A <form> is being closed prematurely (and this is 1381 1231 // malformed HTML). Set an attribute on the form to clear out its … … 1386 1236 // after we complete the close of this entire block. 1387 1237 NodeImpl* currNode = current; 1388 if (isAffectedByStyle && isResidualStyleTag(Elem-> id)) {1238 if (isAffectedByStyle && isResidualStyleTag(Elem->tagName)) { 1389 1239 // We've overloaded the use of stack elements and are just reusing the 1390 1240 // struct with a slightly different meaning to the variables. Instead of chaining … … 1409 1259 } 1410 1260 1411 void KHTMLParser::popOneBlock(bool delBlock)1261 void HTMLParser::popOneBlock(bool delBlock) 1412 1262 { 1413 1263 HTMLStackElem *Elem = blockStack; 1414 1264 1415 1265 // we should never get here, but some bad html might cause it. 1416 #ifndef PARSER_DEBUG 1417 if(!Elem) return; 1418 #else 1419 kdDebug( 6035 ) << "popping block: " << getTagName(Elem->id).string() << "(" << Elem->id << ")" << endl; 1420 #endif 1421 1422 #if SPEED_DEBUG < 1 1423 if((Elem->node != current)) { 1266 if (!Elem) return; 1267 1268 if ((Elem->node != current)) { 1424 1269 if (current->maintainsState() && doc()){ 1425 1270 doc()->registerMaintainsState(current); … … 1432 1277 current->closeRenderer(); 1433 1278 } 1434 #endif1435 1436 removeForbidden(Elem->id, forbiddenTag);1437 1279 1438 1280 blockStack = Elem->next; … … 1446 1288 } 1447 1289 1448 void KHTMLParser::popInlineBlocks()1449 { 1450 while (blockStack && current->isInline())1290 void HTMLParser::popInlineBlocks() 1291 { 1292 while (blockStack && isInline(current)) 1451 1293 popOneBlock(); 1452 1294 } 1453 1295 1454 void KHTMLParser::freeBlock()1296 void HTMLParser::freeBlock() 1455 1297 { 1456 1298 while (blockStack) … … 1458 1300 } 1459 1301 1460 void KHTMLParser::createHead()1302 void HTMLParser::createHead() 1461 1303 { 1462 1304 if(head || !doc()->firstChild()) … … 1475 1317 } 1476 1318 1477 NodeImpl * KHTMLParser::handleIsindex( Token *t )1319 NodeImpl *HTMLParser::handleIsindex( Token *t ) 1478 1320 { 1479 1321 NodeImpl *n; … … 1505 1347 } 1506 1348 1507 void KHTMLParser::startBody()1349 void HTMLParser::startBody() 1508 1350 { 1509 1351 if(inBody) return; … … 1517 1359 } 1518 1360 1519 void KHTMLParser::finished()1361 void HTMLParser::finished() 1520 1362 { 1521 1363 // In the case of a completely empty document, here's the place to create the HTML element. -
trunk/WebCore/khtml/html/htmlparser.h
r8311 r9639 30 30 #define HTMLPARSER_H 31 31 32 // 0 all33 // 1 domtree + rendertree + styleForElement, no layouting34 // 2 domtree only35 #define SPEED_DEBUG 036 37 #ifdef SPEED_DEBUG38 #include <qdatetime.h>39 #endif40 41 32 #include "dom/dom_string.h" 42 33 #include "xml/dom_nodeimpl.h" 43 34 #include "html/html_documentimpl.h" 44 #include "misc/htmltags.h"45 35 46 36 class KHTMLView; … … 62 52 }; 63 53 64 class KHTMLParser;65 66 54 /** 67 55 * The parser for html. It receives a stream of tokens from the HTMLTokenizer, and 68 56 * builds up the Document structure form it. 69 57 */ 70 class KHTMLParser58 class HTMLParser 71 59 { 72 60 public: 73 KHTMLParser(KHTMLView *w, DOM::DocumentPtr *i, bool includesComments=false);74 KHTMLParser(DOM::DocumentFragmentImpl *frag, DOM::DocumentPtr *doc, bool includesComments=false);75 virtual ~ KHTMLParser();61 HTMLParser(KHTMLView *w, DOM::DocumentPtr *i, bool includesComments=false); 62 HTMLParser(DOM::DocumentFragmentImpl *frag, DOM::DocumentPtr *doc, bool includesComments=false); 63 virtual ~HTMLParser(); 76 64 77 65 /** … … 90 78 void reset(); 91 79 92 bool skipMode() const { return (discard_until != 0); }80 bool skipMode() const { return !discard_until.isNull(); } 93 81 bool noSpaces() const { return !inBody; } 94 82 bool selectMode() const { return inSelect; } … … 98 86 99 87 protected: 100 void setCurrent(DOM::NodeImpl *newCurrent); 88 void setCurrent(DOM::NodeImpl* newCurrent); 89 void setSkipMode(const DOM::QualifiedName& qName) { discard_until = qName.localName(); } 101 90 102 91 KHTMLView *HTMLWidget; … … 104 93 105 94 /* 106 * generate a n elementfrom the token95 * generate a node from the token 107 96 */ 108 DOM::NodeImpl *getElement(khtml::Token *); 97 DOM::NodeImpl *getNode(khtml::Token *); 98 bool textCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 99 bool commentCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 100 bool headCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 101 bool bodyCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 102 bool framesetCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 103 bool iframeCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 104 bool formCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 105 bool isindexCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 106 bool selectCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 107 bool ddCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 108 bool dtCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 109 bool nestedCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 110 bool nestedStyleCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 111 bool tableCellCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 112 bool tableSectionCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 113 bool noembedCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 114 bool noscriptCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 115 bool noframesCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 116 bool nolayerCreateErrorCheck(khtml::Token*, DOM::NodeImpl*&); 109 117 110 118 void processCloseTag(khtml::Token *); 111 119 112 120 bool insertNode(DOM::NodeImpl *n, bool flat = false); 121 bool handleError(DOM::NodeImpl* n, bool flat, const DOM::AtomicString& localName, int tagPriority); 122 123 // The currently active element (the one new elements will be added to). Can be a DocumentFragment, a Document or an Element. 124 DOM::NodeImpl* current; 113 125 114 /*115 * The currently active element (the one new elements will be added to)116 */117 DOM::NodeImpl *current;118 126 bool currentIsReferenced; 119 127 120 128 HTMLStackElem *blockStack; 121 129 122 void pushBlock( int _id, int _level);123 124 void popBlock( int _id );130 void pushBlock(const DOM::AtomicString& tagName, int _level); 131 void popBlock(const DOM::AtomicString& tagName); 132 void popBlock(const DOM::QualifiedName& qName) { return popBlock(qName.localName()); } // Convenience function for readability. 125 133 void popOneBlock(bool delBlock = true); 126 134 void popInlineBlocks(); 127 135 128 void freeBlock( void);136 void freeBlock(); 129 137 130 138 void createHead(); 131 139 132 bool isResidualStyleTag( int _id);133 bool isAffectedByResidualStyle( int _id);140 bool isResidualStyleTag(const DOM::AtomicString& tagName); 141 bool isAffectedByResidualStyle(const DOM::AtomicString& tagName); 134 142 void handleResidualStyleCloseTagAcrossBlocks(HTMLStackElem* elem); 135 143 void reopenResidualStyleTags(HTMLStackElem* elem, DOM::NodeImpl* malformedTableParent); 136 144 137 bool allowNestedRedundantTag( int _id);145 bool allowNestedRedundantTag(const DOM::AtomicString& tagName); 138 146 139 static bool isHeaderTag( int _id);147 static bool isHeaderTag(const DOM::AtomicString& tagName); 140 148 void popNestedHeaderTag(); 141 149 150 bool isInline(DOM::NodeImpl* node) const; 151 142 152 /* 143 153 * currently active form … … 176 186 * tells the parser to discard all tags, until it reaches the one specified 177 187 */ 178 intdiscard_until;188 DOM::AtomicString discard_until; 179 189 180 190 bool headLoaded; … … 182 192 183 193 bool includesCommentsInDOM; 194 }; 184 195 185 ushort forbiddenTag[ID_LAST_TAG + 1];186 187 #if SPEED_DEBUG > 0188 QTime qt;189 #endif190 };191 192 196 #endif // HTMLPARSER_H -
trunk/WebCore/khtml/html/htmltokenizer.cpp
r9595 r9639 40 40 #include "html/html_documentimpl.h" 41 41 #include "html/htmlparser.h" 42 #include "html/dtd.h"43 42 44 43 #include "misc/loader.h" … … 64 63 using DOM::DocumentImpl; 65 64 using DOM::emptyAtom; 66 using DOM::endTagRequirement; 65 using DOM::commentAtom; 66 using DOM::nullAtom; 67 using DOM::textAtom; 68 using DOM::HTMLNames; 67 69 68 70 // turn off inlining to void warning with newer gcc … … 240 242 scriptCodeSize = scriptCodeMaxSize = scriptCodeResync = 0; 241 243 charsets = KGlobal::charsets(); 242 parser = new KHTMLParser(_view, _doc, includesComments);244 parser = new HTMLParser(_view, _doc, includesComments); 243 245 m_executingScript = 0; 244 246 loadingExtScript = false; … … 260 262 scriptCodeSize = scriptCodeMaxSize = scriptCodeResync = 0; 261 263 charsets = KGlobal::charsets(); 262 parser = new KHTMLParser(i, _doc, includesComments);264 parser = new HTMLParser(i, _doc, includesComments); 263 265 m_executingScript = 0; 264 266 loadingExtScript = false; … … 452 454 processListing(TokenizerString(scriptCode, scriptCodeSize)); 453 455 processToken(); 454 if ( style ) { currToken. id = ID_STYLE + ID_CLOSE_TAG; }455 else if ( textarea ) { currToken. id = ID_TEXTAREA + ID_CLOSE_TAG; }456 else if ( title ) { currToken. id = ID_TITLE + ID_CLOSE_TAG; }457 else if ( xmp ) { currToken. id = ID_XMP + ID_CLOSE_TAG; }456 if ( style ) { currToken.tagName = HTMLNames::style().localName(); currToken.beginTag = false; } 457 else if ( textarea ) { currToken.tagName = HTMLNames::textarea().localName(); currToken.beginTag = false; } 458 else if ( title ) { currToken.tagName = HTMLNames::title().localName(); currToken.beginTag = false; } 459 else if ( xmp ) { currToken.tagName = HTMLNames::xmp().localName(); currToken.beginTag = false; } 458 460 processToken(); 459 461 style = script = style = textarea = title = xmp = false; … … 525 527 QString exScript( buffer, dest-buffer ); 526 528 processToken(); 527 currToken.id = ID_SCRIPT + ID_CLOSE_TAG; 529 currToken.tagName = HTMLNames::script().localName(); 530 currToken.beginTag = false; 528 531 processToken(); 529 532 … … 702 705 scriptCode[ scriptCodeSize ] = 0; 703 706 scriptCode[ scriptCodeSize + 1 ] = 0; 704 currToken.id = ID_COMMENT; 707 currToken.tagName = commentAtom; 708 currToken.beginTag = true; 705 709 processListing(TokenizerString(scriptCode, scriptCodeSize - endCharsCount)); 706 710 processToken(); 707 currToken.id = ID_COMMENT + ID_CLOSE_TAG; 711 currToken.tagName = commentAtom; 712 currToken.beginTag = false; 708 713 processToken(); 709 714 } … … 1023 1028 break; 1024 1029 } 1025 // Use tolower() instead of | 0x20 to lowercase the char because there is no 1026 // performance gain in using | 0x20 since tolower() is optimized and 1027 // | 0x20 turns characters such as '_' into junk. 1028 cBuffer[cBufferPos++] = tolower(curchar); 1030 1031 // tolower() shows up on profiles. This is faster! 1032 if (curchar >= 'A' && curchar <= 'Z') 1033 cBuffer[cBufferPos++] = curchar + ('a' - 'A'); 1034 else 1035 cBuffer[cBufferPos++] = curchar; 1029 1036 ++src; 1030 1037 } … … 1048 1055 beginTag = true; 1049 1056 1050 // Accept empty xml tags like <br/>. We trim off the "/" so that when we call 1051 // getTagID, we'll look up "br" as the tag name and not "br/". 1057 // Ignore the / in fake xml tags like <br/>. We trim off the "/" so that we'll get "br" as the tag name and not "br/". 1052 1058 if(len > 1 && ptr[len-1] == '/' ) 1053 1059 ptr[--len] = '\0'; 1054 1060 1055 // Look up the tagID for the specified tag name (now that we've shaved off any 1056 // invalid / that might have followed the name). 1057 unsigned short tagID = getTagID(ptr, len); 1058 if (!tagID) { 1059 DOMString tagName(ptr); 1060 DocumentImpl *doc = parser->docPtr()->document(); 1061 if (doc->isValidName(tagName)) 1062 tagID = parser->docPtr()->document()->tagId(0, tagName.implementation(), false); 1063 } 1064 if (tagID) { 1065 #ifdef TOKEN_DEBUG 1066 QCString tmp(ptr, len+1); 1067 kdDebug( 6036 ) << "found tag id=" << tagID << ": " << tmp.data() << endl; 1068 #endif 1069 currToken.id = beginTag ? tagID : tagID + ID_CLOSE_TAG; 1070 } 1061 // Now that we've shaved off any invalid / that might have followed the name), make the tag. 1062 currToken.tagName = AtomicString(ptr); 1063 currToken.beginTag = beginTag; 1071 1064 dest = buffer; 1072 1065 tag = SearchAttribute; … … 1119 1112 attrName = QString::fromLatin1(QCString(cBuffer, cBufferPos+1).data()); 1120 1113 attrNamePresent = !attrName.isEmpty(); 1121 1122 // This is a deliberate quirk to match Mozilla and Opera. We have to do this1123 // since sites that use the "standards-compliant" path sometimes send1124 // <script src="foo.js"/>. Both Moz and Opera will honor this, despite it1125 // being bogus HTML. They do not honor the "/" for other tags. This behavior1126 // also deviates from WinIE, but in this case we'll just copy Moz and Opera.1127 if (currToken.id == ID_SCRIPT && curchar == '>' &&1128 attrName == "/")1129 currToken.flat = true;1130 1114 } 1131 1115 … … 1143 1127 } 1144 1128 } 1145 // Use tolower() instead of | 0x20 to lowercase the char because there is no 1146 // performance gain in using | 0x20 since tolower() is optimized and 1147 // | 0x20 turns characters such as '_' into junk. 1148 cBuffer[cBufferPos++] = tolower(curchar); 1129 1130 // tolower() shows up on profiles. This is faster! 1131 if (curchar >= 'A' && curchar <= 'Z') 1132 cBuffer[cBufferPos++] = curchar + ('a' - 'A'); 1133 else 1134 cBuffer[cBufferPos++] = curchar; 1149 1135 ++src; 1150 1136 } … … 1329 1315 ++src; 1330 1316 1331 if ( !currToken.id) //stop if tag is unknown1317 if (currToken.tagName == nullAtom) //stop if tag is unknown 1332 1318 return; 1333 1319 1334 uint tagID = currToken.id;1320 AtomicString tagName = currToken.tagName; 1335 1321 #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 0 1336 1322 kdDebug( 6036 ) << "appending Tag: " << tagID << endl; 1337 1323 #endif 1338 bool beginTag = !currToken.flat && (tagID <= ID_CLOSE_TAG); 1339 1340 if (tagID > ID_CLOSE_TAG) 1341 tagID -= ID_CLOSE_TAG; 1342 else if (tagID == ID_SCRIPT) { 1324 bool beginTag = !currToken.flat && currToken.beginTag; 1325 if (beginTag && currToken.tagName == HTMLNames::script()) { 1343 1326 AttributeImpl* a = 0; 1344 1327 bool foundTypeAttribute = false; … … 1415 1398 processToken(); 1416 1399 1417 // we have to take care to close the pre block in 1418 // case we encounter an unallowed element.... 1419 if(pre && beginTag && !DOM::checkChild(ID_PRE, tagID, !parser->doc()->inCompatMode())) { 1420 kdDebug(6036) << " not allowed in <pre> " << (int)tagID << endl; 1421 pre = false; 1422 } 1423 1424 switch( tagID ) { 1425 case ID_PRE: 1400 if (tagName == HTMLNames::pre()) { 1426 1401 prePos = 0; 1427 1402 pre = beginTag; 1428 1403 discard = LFDiscard; // Discard the first LF after we open a pre. 1429 break; 1430 case ID_SCRIPT: 1404 } else if (tagName == HTMLNames::script()) { 1431 1405 if (beginTag) { 1432 1406 searchStopper = scriptEnd; … … 1435 1409 parseSpecial(src); 1436 1410 } 1437 else if (tagID <= ID_CLOSE_TAG) { // Handle <script src="foo"/> 1438 script = true; 1439 scriptHandler(); 1440 } 1441 break; 1442 case ID_STYLE: 1411 } else if (tagName == HTMLNames::style()) { 1443 1412 if (beginTag) { 1444 1413 searchStopper = styleEnd; … … 1447 1416 parseSpecial(src); 1448 1417 } 1449 break; 1450 case ID_TEXTAREA: 1418 } else if (tagName == HTMLNames::textarea()) { 1451 1419 if(beginTag) { 1452 1420 searchStopper = textareaEnd; … … 1455 1423 parseSpecial(src); 1456 1424 } 1457 break; 1458 case ID_TITLE: 1459 if (beginTag) { 1425 } else if (tagName == HTMLNames::title()) { 1426 if (beginTag) { 1460 1427 searchStopper = titleEnd; 1461 1428 searchStopperLen = 7; … … 1463 1430 parseSpecial(src); 1464 1431 } 1465 break; 1466 case ID_XMP: 1432 } else if (tagName == HTMLNames::xmp()) { 1467 1433 if (beginTag) { 1468 1434 searchStopper = xmpEnd; … … 1471 1437 parseSpecial(src); 1472 1438 } 1473 break; 1474 case ID_SELECT: 1439 } else if (tagName == HTMLNames::select()) 1475 1440 select = beginTag; 1476 break; 1477 case ID_PLAINTEXT: 1441 else if (tagName == HTMLNames::plaintext()) 1478 1442 plaintext = beginTag; 1479 break;1480 }1481 1482 1443 return; // Finished parsing tag! 1483 1444 } … … 1990 1951 currToken.text = new DOMStringImpl( buffer, dest - buffer ); 1991 1952 currToken.text->ref(); 1992 if (currToken. id != ID_COMMENT)1993 currToken. id = ID_TEXT;1994 } 1995 else if (!currToken.id) {1953 if (currToken.tagName != commentAtom) 1954 currToken.tagName = textAtom; 1955 } 1956 else if (currToken.tagName == nullAtom) { 1996 1957 currToken.reset(); 1997 1958 if (jsProxy) -
trunk/WebCore/khtml/html/htmltokenizer.h
r9595 r9639 35 35 36 36 #include "misc/loader_client.h" 37 #include "misc/htmltags.h"38 #include "xml/dom_stringimpl.h"39 37 #include "xml/xml_tokenizer.h" 40 38 #include "html/html_elementimpl.h" … … 48 46 49 47 class KCharsets; 50 class KHTMLParser;48 class HTMLParser; 51 49 class KHTMLView; 52 50 … … 71 69 public: 72 70 Token() { 73 id = 0;74 71 attrs = 0; 75 72 text = 0; 73 beginTag = true; 76 74 flat = false; 77 75 //qDebug("new token, creating %08lx", attrs); 78 76 } 77 79 78 ~Token() { 80 if(attrs) attrs->deref(); 81 if(text) text->deref(); 82 } 79 if (attrs) attrs->deref(); 80 if (text) text->deref(); 81 } 82 83 83 void addAttribute(DOM::DocumentImpl* doc, QChar* buffer, const QString& attrName, const DOM::AtomicString& v) 84 84 { 85 85 DOM::AttributeImpl* a = 0; 86 if (buffer->unicode())86 if (buffer->unicode()) 87 87 a = new DOM::MappedAttributeImpl(buffer->unicode(), v); 88 else if ( !attrName.isEmpty() && attrName != "/")88 else if (!attrName.isEmpty() && attrName != "/") 89 89 a = new DOM::MappedAttributeImpl(doc->attrId(0, DOM::DOMString(attrName).implementation(), false), 90 90 v); … … 98 98 } 99 99 } 100 101 bool isOpenTag(const DOM::QualifiedName& fullName) const { return beginTag && fullName.localName() == tagName; } 102 bool isCloseTag(const DOM::QualifiedName& fullName) const { return !beginTag && fullName.localName() == tagName; } 103 100 104 void reset() 101 105 { 102 if (attrs) {106 if (attrs) { 103 107 attrs->deref(); 104 108 attrs = 0; 105 109 } 106 id = 0; 107 if(text) { 110 111 tagName = DOM::nullAtom; 112 113 if (text) { 108 114 text->deref(); 109 115 text = 0; 110 116 } 117 118 beginTag = true; 111 119 flat = false; 112 120 } 121 113 122 DOM::NamedMappedAttrMapImpl* attrs; 114 123 DOM::DOMStringImpl* text; 115 ushort id; 116 bool flat; 124 DOM::AtomicString tagName; 125 bool beginTag : 1; 126 bool flat : 1; 117 127 }; 118 128 … … 369 379 370 380 KCharsets *charsets; 371 KHTMLParser *parser;381 HTMLParser *parser; 372 382 373 383 QGuardedPtr<KHTMLView> view; -
trunk/WebCore/khtml/khtml_part.cpp
r9517 r9639 209 209 { 210 210 AtomicString::init(); 211 HTMLNames::init(); // FIXME: We should make this happen only when HTML is used. 211 212 if ( prof == DefaultGUI ) 212 213 setXMLFile( "khtml.rc" ); … … 5725 5726 5726 5727 if (d->m_typingStyle) { 5727 styleElement = xmlDocImpl()->create HTMLElement("span", exceptionCode);5728 styleElement = xmlDocImpl()->createElementNS(HTMLNames::xhtmlNamespaceURI(), "span", exceptionCode); 5728 5729 assert(exceptionCode == 0); 5729 5730 -
trunk/WebCore/khtml/khtmlview.cpp
r9156 r9639 608 608 NodeImpl *body = static_cast<HTMLDocumentImpl*>(document)->body(); 609 609 if (body && body->renderer()) { 610 if (body-> id() == ID_FRAMESET) {610 if (body->hasTagName(HTMLNames::frameset())) { 611 611 body->renderer()->setNeedsLayout(true); 612 612 vMode = AlwaysOff; 613 613 hMode = AlwaysOff; 614 614 } 615 else if (body-> id() == ID_BODY) {615 else if (body->hasTagName(HTMLNames::body())) { 616 616 RenderObject* o = (rootRenderer->style()->overflow() == OVISIBLE) ? body->renderer() : rootRenderer; 617 617 applyOverflowToViewport(o, hMode, vMode); // Only applies to HTML UAs, not to XML/XHTML UAs … … 878 878 static bool isSubmitImage(DOM::NodeImpl *node) 879 879 { 880 return node 881 && node->isHTMLElement() 882 && node->id() == ID_INPUT 883 && static_cast<HTMLInputElementImpl*>(node)->inputType() == HTMLInputElementImpl::IMAGE; 880 return node && node->hasTagName(HTMLNames::input()) && static_cast<HTMLInputElementImpl*>(node)->inputType() == HTMLInputElementImpl::IMAGE; 884 881 } 885 882 -
trunk/WebCore/khtml/misc/decoder.cpp
r9513 r9639 41 41 #include <kdebug.h> 42 42 #include <klocale.h> 43 44 #include "htmlnames.h" 45 46 using DOM::AtomicString; 47 using DOM::HTMLNames; 48 using DOM::nullAtom; 43 49 44 50 class KanjiCode … … 527 533 } 528 534 tmp[len] = 0; 529 int id = khtml::getTagID(tmp, len); 530 if(end) id += ID_CLOSE_TAG; 531 532 switch( id ) { 533 case ID_META: 534 { 535 AtomicString tag(tmp); 536 if (!end && tag == HTMLNames::meta()) { 535 537 // found a meta tag... 536 538 //ptr += 5; … … 571 573 pos = endpos + 1; 572 574 } 573 } 574 case (ID_META+ID_CLOSE_TAG): 575 case ID_SCRIPT: 576 case (ID_SCRIPT+ID_CLOSE_TAG): 577 case ID_NOSCRIPT: 578 case (ID_NOSCRIPT+ID_CLOSE_TAG): 579 case ID_STYLE: 580 case (ID_STYLE+ID_CLOSE_TAG): 581 case ID_LINK: 582 case (ID_LINK+ID_CLOSE_TAG): 583 case ID_OBJECT: 584 case (ID_OBJECT+ID_CLOSE_TAG): 585 case ID_TITLE: 586 case (ID_TITLE+ID_CLOSE_TAG): 587 case ID_BASE: 588 case (ID_BASE+ID_CLOSE_TAG): 589 case ID_HTML: 590 case ID_HEAD: 591 case 0: 592 case (0 + ID_CLOSE_TAG ): 593 break; 594 default: 575 } else if (tag != HTMLNames::script() && tag != HTMLNames::noscript() && tag != HTMLNames::style() && 576 tag != HTMLNames::link() && tag != HTMLNames::meta() && tag != HTMLNames::object() && 577 tag != HTMLNames::title() && tag != HTMLNames::base() && 578 (end || tag != HTMLNames::html()) && 579 (end || tag != HTMLNames::head()) && isalpha(tmp[0])) { 595 580 body = true; 596 581 #ifdef DECODE_DEBUG -
trunk/WebCore/khtml/misc/hashmap.h
r9597 r9639 76 76 77 77 template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits> 78 in t HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::size() const78 inline int HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::size() const 79 79 { 80 return m_impl. count();80 return m_impl.size(); 81 81 } 82 82 … … 88 88 89 89 template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits> 90 bool HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::isEmpty() const90 inline bool HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::isEmpty() const 91 91 { 92 92 return size() == 0; … … 94 94 95 95 template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits> 96 typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::iterator HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::begin()96 inline typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::iterator HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::begin() 97 97 { 98 98 return m_impl.begin(); … … 100 100 101 101 template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits> 102 typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::iterator HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::end()102 inline typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::iterator HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::end() 103 103 { 104 104 return m_impl.end(); … … 106 106 107 107 template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits> 108 typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::const_iterator HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::begin() const108 inline typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::const_iterator HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::begin() const 109 109 { 110 110 return m_impl.begin(); … … 112 112 113 113 template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits> 114 typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::const_iterator HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::end() const114 inline typename HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::const_iterator HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::end() const 115 115 { 116 116 return m_impl.end(); … … 149 149 150 150 template<typename Key, typename Mapped, typename HashFunctions, typename KeyTraits, typename MappedTraits> 151 Mapped HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::get(const KeyType &key) const151 inline Mapped HashMap<Key, Mapped, HashFunctions, KeyTraits, MappedTraits>::get(const KeyType &key) const 152 152 { 153 153 const_iterator it = find(key); -
trunk/WebCore/khtml/misc/hashset.h
r9605 r9639 83 83 84 84 template<typename Value, typename HashFunctions, typename Traits> 85 in t HashSet<Value, HashFunctions, Traits>::size() const85 inline int HashSet<Value, HashFunctions, Traits>::size() const 86 86 { 87 87 return m_impl.size(); … … 95 95 96 96 template<typename Value, typename HashFunctions, typename Traits> 97 bool HashSet<Value, HashFunctions, Traits>::isEmpty() const97 inline bool HashSet<Value, HashFunctions, Traits>::isEmpty() const 98 98 { 99 99 return size() == 0; … … 101 101 102 102 template<typename Value, typename HashFunctions, typename Traits> 103 typename HashSet<Value, HashFunctions, Traits>::iterator HashSet<Value, HashFunctions, Traits>::begin()103 inline typename HashSet<Value, HashFunctions, Traits>::iterator HashSet<Value, HashFunctions, Traits>::begin() 104 104 { 105 105 return m_impl.begin(); … … 107 107 108 108 template<typename Value, typename HashFunctions, typename Traits> 109 typename HashSet<Value, HashFunctions, Traits>::iterator HashSet<Value, HashFunctions, Traits>::end()109 inline typename HashSet<Value, HashFunctions, Traits>::iterator HashSet<Value, HashFunctions, Traits>::end() 110 110 { 111 111 return m_impl.end(); … … 113 113 114 114 template<typename Value, typename HashFunctions, typename Traits> 115 typename HashSet<Value, HashFunctions, Traits>::const_iterator HashSet<Value, HashFunctions, Traits>::begin() const115 inline typename HashSet<Value, HashFunctions, Traits>::const_iterator HashSet<Value, HashFunctions, Traits>::begin() const 116 116 { 117 117 return m_impl.begin(); … … 119 119 120 120 template<typename Value, typename HashFunctions, typename Traits> 121 typename HashSet<Value, HashFunctions, Traits>::const_iterator HashSet<Value, HashFunctions, Traits>::end() const121 inline typename HashSet<Value, HashFunctions, Traits>::const_iterator HashSet<Value, HashFunctions, Traits>::end() const 122 122 { 123 123 return m_impl.end(); … … 137 137 138 138 template<typename Value, typename HashFunctions, typename Traits> 139 bool HashSet<Value, HashFunctions, Traits>::contains(const ValueType& value) const139 inline bool HashSet<Value, HashFunctions, Traits>::contains(const ValueType& value) const 140 140 { 141 141 return m_impl.contains(value); -
trunk/WebCore/khtml/misc/hashtable.h
r9617 r9639 67 67 friend class HashTable<Key, Value, ExtractKey, HashFunctions, Traits>; 68 68 69 void skipEmptyBuckets() 70 { 71 while (m_position != m_endPosition && (HashTableType::isEmptyOrDeletedBucket(*m_position))) { 72 ++m_position; 73 } 74 } 75 69 76 HashTableIterator(PointerType position, PointerType endPosition) 70 77 : m_position(position), m_endPosition(endPosition) … … 100 107 } 101 108 102 private: 103 void skipEmptyBuckets() 104 { 105 while (m_position != m_endPosition && (HashTableType::isEmptyOrDeletedBucket(*m_position))) { 106 ++m_position; 107 } 108 } 109 109 private: 110 110 PointerType m_position; 111 111 PointerType m_endPosition; … … 272 272 inline typename HashTable<Key, Value, ExtractKey, HashFunctions, Traits>::FullLookupType HashTable<Key, Value, ExtractKey, HashFunctions, Traits>::lookup(const T& key) 273 273 { 274 if (!m_table) 275 return makeLookupResult(0, false, 0); 274 assert(m_table); 276 275 277 276 unsigned h = HashT(key); 278 int i = h & m_tableSizeMask; 277 int sizeMask = m_tableSizeMask; 278 int i = h & sizeMask; 279 279 int k = 0; 280 280 … … 284 284 #endif 285 285 286 ValueType *table = m_table; 286 287 ValueType *entry; 287 288 ValueType *deletedEntry = 0; 288 while (!isEmptyBucket(*(entry = m_table + i))) {289 while (!isEmptyBucket(*(entry = table + i))) { 289 290 if (isDeletedBucket(*entry)) 290 291 deletedEntry = entry; … … 296 297 #endif 297 298 if (k == 0) 298 k = 1 | (h % m_tableSizeMask);299 i = (i + k) & m_tableSizeMask;299 k = 1 | (h % sizeMask); 300 i = (i + k) & sizeMask; 300 301 } 301 302 … … 356 357 inline typename HashTable<Key, Value, ExtractKey, HashFunctions, Traits>::iterator HashTable<Key, Value, ExtractKey, HashFunctions, Traits>::find(const Key& key) 357 358 { 359 if (!m_table) 360 return end(); 361 358 362 LookupType result = lookup(key); 359 363 if (!result.second) … … 365 369 inline typename HashTable<Key, Value, ExtractKey, HashFunctions, Traits>::const_iterator HashTable<Key, Value, ExtractKey, HashFunctions, Traits>::find(const Key& key) const 366 370 { 371 if (!m_table) 372 return end(); 373 367 374 LookupType result = const_cast<HashTable *>(this)->lookup(key); 368 375 if (!result.second) … … 374 381 inline bool HashTable<Key, Value, ExtractKey, HashFunctions, Traits>::contains(const KeyType& key) const 375 382 { 383 if (!m_table) 384 return false; 385 376 386 return const_cast<HashTable *>(this)->lookup(key).second; 377 387 } … … 399 409 inline void HashTable<Key, Value, ExtractKey, HashFunctions, Traits>::remove(const KeyType& key) 400 410 { 411 if (!m_table) 412 return; 413 401 414 remove(lookup(key).first); 402 415 } -
trunk/WebCore/khtml/misc/htmlhashes.cpp
r8306 r9639 26 26 #undef __inline 27 27 #define __inline 28 #include "htmltags.c"29 28 #include "htmlattrs.c" 30 29 #undef __inline 31 30 32 unsigned short khtml::get TagID(const char *tagStr, int len)31 unsigned short khtml::getAttrID(const char *attrStr, int len) 33 32 { 34 const struct tags *tagPtr = findTag(tagStr, len);35 if (! tagPtr)33 const struct attrs *attrPtr = findAttr(attrStr, len); 34 if (!attrPtr) 36 35 return 0; 37 return tagPtr->id;36 return attrPtr->id; 38 37 } 39 40 unsigned short khtml::getAttrID(const char *tagStr, int len)41 {42 const struct attrs *tagPtr = findAttr(tagStr, len);43 if (!tagPtr)44 return 0;45 return tagPtr->id;46 } -
trunk/WebCore/khtml/misc/htmlhashes.h
r8306 r9639 24 24 #define HTMLHASHES_H 25 25 26 #include "htmltags.h"27 26 #include "htmlattrs.h" 28 27 29 28 namespace khtml 30 29 { 31 unsigned short getTagID(const char *tagStr, int len);32 30 unsigned short getAttrID(const char *tagStr, int len); 33 31 } -
trunk/WebCore/khtml/rendering/bidi.cpp
r9596 r9639 361 361 return QChar::DirON; 362 362 363 RenderText *renderTxt = static_cast<RenderText *>( obj);364 if ( pos >= renderTxt->stringLength())363 RenderText *renderTxt = static_cast<RenderText *>(obj); 364 if (pos >= renderTxt->stringLength()) 365 365 return QChar::DirON; 366 367 366 return renderTxt->text()[pos].direction(); 368 367 } -
trunk/WebCore/khtml/rendering/break_lines.cpp
r9595 r9639 113 113 return true; 114 114 115 return c->direction() == QChar::DirWS; 115 // No other ascii chars are breakable. 116 return false; 116 117 #endif 117 118 } -
trunk/WebCore/khtml/rendering/render_applet.cpp
r9151 r9639 37 37 38 38 #include "java/kjavaappletwidget.h" 39 #include "misc/htmltags.h"40 39 #include "html/html_objectimpl.h" 41 40 … … 104 103 NodeImpl *child = element()->firstChild(); 105 104 while (child) { 106 if (child-> id() == ID_PARAM) {105 if (child->hasTagName(HTMLNames::param())) { 107 106 HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>(child); 108 107 m_args.insert(p->name().string(), p->value().string()); -
trunk/WebCore/khtml/rendering/render_block.cpp
r9595 r9639 41 41 #include "khtmlview.h" 42 42 #include "khtml_part.h" 43 #include "htmltags.h"44 43 45 44 using namespace DOM; … … 476 475 m_bottomMarginQuirk = style()->marginBottom().quirk; 477 476 478 if (element() && element()-> id() == ID_FORM&& element()->isMalformed())477 if (element() && element()->hasTagName(HTMLNames::form()) && element()->isMalformed()) 479 478 // See if this form is malformed (i.e., unclosed). If so, don't give the form 480 479 // a bottom margin. -
trunk/WebCore/khtml/rendering/render_box.cpp
r9357 r9639 257 257 // render object very easily via the DOM. 258 258 HTMLElementImpl* body = document()->body(); 259 RenderObject* bodyObject = (body && body-> id() == ID_BODY) ? body->renderer() : 0;259 RenderObject* bodyObject = (body && body->hasLocalName(HTMLNames::body())) ? body->renderer() : 0; 260 260 if (bodyObject) { 261 261 bgLayer = bodyObject->style()->backgroundLayers(); … … 370 370 DOM::NodeImpl* elt = document()->ownerElement(); 371 371 if (elt) { 372 if (elt-> id() == ID_FRAME)372 if (elt->hasTagName(HTMLNames::frame())) 373 373 isTransparent = false; 374 374 else { … … 378 378 // render object very easily via the DOM. 379 379 HTMLElementImpl* body = document()->body(); 380 isTransparent = !body || body->id() != ID_FRAMESET; // Can't scroll a frameset document anyway.380 isTransparent = !body || !body->hasLocalName(HTMLNames::frameset()); // Can't scroll a frameset document anyway. 381 381 } 382 382 } else -
trunk/WebCore/khtml/rendering/render_canvasimage.cpp
r9608 r9639 38 38 #include "misc/helper.h" 39 39 #include "misc/htmlattrs.h" 40 #include "misc/htmltags.h"41 40 #include "html/html_formimpl.h" 42 41 #include "html/html_canvasimpl.h" 43 #include "html/dtd.h"44 42 #include "xml/dom2_eventsimpl.h" 45 43 #include "html/html_documentimpl.h" … … 192 190 193 191 if (drawnImage()) { 194 HTMLCanvasElementImpl* i = (element() && element()-> id() == ID_CANVAS) ? static_cast<HTMLCanvasElementImpl*>(element()) : 0;192 HTMLCanvasElementImpl* i = (element() && element()->hasTagName(HTMLNames::canvas())) ? static_cast<HTMLCanvasElementImpl*>(element()) : 0; 195 193 int oldOperation = 0; 196 194 if (i && !i->compositeOperator().isNull()){ -
trunk/WebCore/khtml/rendering/render_canvasimage.h
r7457 r9639 27 27 #define RENDER_CANVASIMAGE_H 28 28 29 #include "html/dtd.h"30 29 #include "html/html_elementimpl.h" 31 30 #include "rendering/render_image.h" -
trunk/WebCore/khtml/rendering/render_container.cpp
r8589 r9639 227 227 // For <q><p/></q>, if this object is the inline continuation of the <q>, we only want to generate 228 228 // :after content and not :before content. 229 if ( type == RenderStyle::BEFORE && isInlineContinuation())229 if (newContentWanted && type == RenderStyle::BEFORE && isInlineContinuation()) 230 230 newContentWanted = false; 231 231 232 232 // Similarly, if we're the beginning of a <q>, and there's an inline continuation for our object, 233 233 // then we don't generate the :after content. 234 if ( type == RenderStyle::AFTER && isRenderInline() && continuation())234 if (newContentWanted && type == RenderStyle::AFTER && isRenderInline() && continuation()) 235 235 newContentWanted = false; 236 236 -
trunk/WebCore/khtml/rendering/render_flow.cpp
r9157 r9639 41 41 42 42 #include "khtmlview.h" 43 #include "htmltags.h"44 43 45 44 using namespace DOM; … … 655 654 // But skip the body element if it is outermost. 656 655 if (element() && element()->isContentEditable()) { 657 if (element()->parentNode() && !element()->parentNode()->isContentEditable() && element()->id() != ID_BODY)656 if (element()->parentNode() && !element()->parentNode()->isContentEditable() && !element()->hasTagName(HTMLNames::body())) 658 657 p->addFocusRingRect(_tx, _ty, width(), height()); 659 658 return; -
trunk/WebCore/khtml/rendering/render_form.cpp
r9479 r9639 798 798 for (RenderObject* legend = firstChild(); legend; legend = legend->nextSibling()) { 799 799 if (!legend->isFloatingOrPositioned() && legend->element() && 800 legend->element()-> id() == ID_LEGEND)800 legend->element()->hasTagName(HTMLNames::legend())) 801 801 return legend; 802 802 } … … 1192 1192 1193 1193 for (listIndex = 0; listIndex < int(listItems.size()); listIndex++) { 1194 if (listItems[listIndex]-> id() == ID_OPTGROUP) {1194 if (listItems[listIndex]->hasTagName(HTMLNames::optgroup())) { 1195 1195 QString label = listItems[listIndex]->getAttribute(ATTR_LABEL).string(); 1196 1196 label.replace(QChar('\\'), backslashAsCurrencySymbol()); … … 1216 1216 #endif 1217 1217 } 1218 else if (listItems[listIndex]-> id() == ID_OPTION) {1218 else if (listItems[listIndex]->hasTagName(HTMLNames::option())) { 1219 1219 QString itemText = static_cast<HTMLOptionElementImpl*>(listItems[listIndex])->text().string(); 1220 1220 itemText.replace(QChar('\\'), backslashAsCurrencySymbol()); … … 1223 1223 itemText = itemText.stripWhiteSpace(); 1224 1224 1225 if (listItems[listIndex]->parentNode()-> id() == ID_OPTGROUP)1225 if (listItems[listIndex]->parentNode()->hasTagName(HTMLNames::optgroup())) 1226 1226 itemText.prepend(" "); 1227 1227 … … 1349 1349 bool foundOption = false; 1350 1350 for (uint i = 0; i < listItems.size() && !foundOption; i++) 1351 foundOption = (listItems[i]-> id() == ID_OPTION);1351 foundOption = (listItems[i]->hasTagName(HTMLNames::option())); 1352 1352 1353 1353 m_widget->setEnabled(foundOption && ! element()->disabled()); … … 1363 1363 if(index >= 0 && index < int(listItems.size())) 1364 1364 { 1365 bool found = ( listItems[index]->id() == ID_OPTION);1365 bool found = (listItems[index]->hasTagName(HTMLNames::option())); 1366 1366 1367 1367 if ( !found ) { 1368 1368 // this one is not selectable, we need to find an option element 1369 1369 while ( ( unsigned ) index < listItems.size() ) { 1370 if ( listItems[index]->id() == ID_OPTION) {1370 if (listItems[index]->hasTagName(HTMLNames::option())) { 1371 1371 found = true; 1372 1372 break; … … 1377 1377 if ( !found ) { 1378 1378 while ( index >= 0 ) { 1379 if ( listItems[index]->id() == ID_OPTION) {1379 if (listItems[index]->hasTagName(HTMLNames::option())) { 1380 1380 found = true; 1381 1381 break; … … 1391 1391 1392 1392 for ( unsigned int i = 0; i < listItems.size(); ++i ) 1393 if ( listItems[i]->id() == ID_OPTION && i != (unsigned int) index)1393 if (listItems[i]->hasTagName(HTMLNames::option()) && i != (unsigned int) index) 1394 1394 static_cast<HTMLOptionElementImpl*>( listItems[i] )->m_selected = false; 1395 1395 … … 1412 1412 // don't use setSelected() here because it will cause us to be called 1413 1413 // again with updateSelection. 1414 if ( listItems[i]->id() == ID_OPTION)1414 if (listItems[i]->hasTagName(HTMLNames::option())) 1415 1415 static_cast<HTMLOptionElementImpl*>( listItems[i] ) 1416 1416 ->m_selected = static_cast<KListBox*>( m_widget )->isSelected( i ); … … 1454 1454 KListBox *listBox = static_cast<KListBox*>(m_widget); 1455 1455 for (i = 0; i < int(listItems.size()); i++) 1456 listBox->setSelected(i, listItems[i]->id() == ID_OPTION&&1456 listBox->setSelected(i, listItems[i]->hasTagName(HTMLNames::option()) && 1457 1457 static_cast<HTMLOptionElementImpl*>(listItems[i])->selected()); 1458 1458 } … … 1462 1462 i = listItems.size(); 1463 1463 while (i--) 1464 if (listItems[i]-> id() == ID_OPTION) {1464 if (listItems[i]->hasTagName(HTMLNames::option())) { 1465 1465 if (found) 1466 1466 static_cast<HTMLOptionElementImpl*>(listItems[i])->m_selected = false; -
trunk/WebCore/khtml/rendering/render_frames.cpp
r9151 r9639 35 35 #include "xml/dom2_eventsimpl.h" 36 36 #include "xml/dom_docimpl.h" 37 #include "misc/htmltags.h"38 37 #include "khtmlview.h" 39 38 #include "khtml_part.h" … … 670 669 setNeedsLayoutAndMinMaxRecalc(); 671 670 672 if (element()-> id() == ID_OBJECT) {671 if (element()->hasTagName(HTMLNames::object())) { 673 672 674 673 HTMLObjectElementImpl *o = static_cast<HTMLObjectElementImpl *>(element()); … … 677 676 HTMLEmbedElementImpl *embed = 0; 678 677 for (NodeImpl *child = o->firstChild(); child; ) { 679 if (child-> id() == ID_EMBED) {678 if (child->hasTagName(HTMLNames::embed())) { 680 679 embed = static_cast<HTMLEmbedElementImpl *>( child ); 681 680 break; 682 } else if (child-> id() == ID_OBJECT) {681 } else if (child->hasTagName(HTMLNames::object())) { 683 682 child = child->nextSibling(); // Don't descend into nested OBJECT tags 684 683 } else { … … 720 719 NodeImpl *child = o->firstChild(); 721 720 while (child && (url.isEmpty() || serviceType.isEmpty() || !embed)) { 722 if (child-> id() == ID_PARAM) {721 if (child->hasTagName(HTMLNames::param())) { 723 722 HTMLParamElementImpl *p = static_cast<HTMLParamElementImpl *>( child ); 724 723 QString name = p->name().string().lower(); … … 811 810 m_hasFallbackContent = false; 812 811 for (NodeImpl *child = o->firstChild(); child && !m_hasFallbackContent; child = child->nextSibling()) { 813 if ((!child->isTextNode() && child->id() != ID_EMBED && child->id() != ID_PARAM) || // Discount <embed> and <param>812 if ((!child->isTextNode() && !child->hasTagName(HTMLNames::embed()) && !child->hasTagName(HTMLNames::param())) || // Discount <embed> and <param> 814 813 (child->isTextNode() && !child->containsOnlyWhitespace())) 815 814 m_hasFallbackContent = true; … … 818 817 if (!success && m_hasFallbackContent) 819 818 o->renderFallbackContent(); 820 } else if ( element()->id() == ID_EMBED) {819 } else if (element()->hasTagName(HTMLNames::embed())) { 821 820 822 821 HTMLEmbedElementImpl *o = static_cast<HTMLEmbedElementImpl *>(element()); … … 845 844 part->requestObject( this, url, serviceType, paramNames, paramValues ); 846 845 } else { 847 assert(element()-> id() == ID_IFRAME);846 assert(element()->hasTagName(HTMLNames::iframe())); 848 847 HTMLIFrameElementImpl *o = static_cast<HTMLIFrameElementImpl *>(element()); 849 848 url = o->m_URL.string(); … … 891 890 int marginw = -1; 892 891 int marginh = -1; 893 if ( element()->id() == ID_IFRAME) {892 if (element()->hasTagName(HTMLNames::iframe())) { 894 893 HTMLIFrameElementImpl *frame = static_cast<HTMLIFrameElementImpl *>(element()); 895 894 if(frame->m_frameBorder) … … 911 910 #endif 912 911 KHTMLView *htmlView = static_cast<KHTMLView *>(view); 913 htmlView->setIgnoreWheelEvents( element()->id() == ID_IFRAME);912 htmlView->setIgnoreWheelEvents(element()->hasTagName(HTMLNames::iframe())); 914 913 if(marginw != -1) htmlView->setMarginWidth(marginw); 915 914 if(marginh != -1) htmlView->setMarginHeight(marginh); -
trunk/WebCore/khtml/rendering/render_image.cpp
r9608 r9639 38 38 #include "misc/helper.h" 39 39 #include "misc/htmlattrs.h" 40 #include "misc/htmltags.h"41 40 #include "html/html_formimpl.h" 42 41 #include "html/html_imageimpl.h" 43 #include "html/dtd.h"44 42 #include "xml/dom2_eventsimpl.h" 45 43 #include "html/html_documentimpl.h" … … 425 423 426 424 // p->drawPixmap( offs.x(), y, pix, rect.x(), rect.y(), rect.width(), rect.height() ); 427 HTMLImageElementImpl* i = (element() && element()-> id() == ID_IMG) ? static_cast<HTMLImageElementImpl*>(element()) : 0;425 HTMLImageElementImpl* i = (element() && element()->hasTagName(HTMLNames::img())) ? static_cast<HTMLImageElementImpl*>(element()) : 0; 428 426 if (i && !i->compositeOperator().isNull()){ 429 427 p->drawPixmap (offs, pix, rect, i->compositeOperator()); … … 492 490 HTMLMapElementImpl* RenderImage::imageMap() 493 491 { 494 HTMLImageElementImpl* i = element()-> id() == ID_IMG? static_cast<HTMLImageElementImpl*>(element()) : 0;492 HTMLImageElementImpl* i = element()->hasTagName(HTMLNames::img()) ? static_cast<HTMLImageElementImpl*>(element()) : 0; 495 493 return i ? i->getDocument()->getImageMap(i->imageMap()) : 0; 496 494 } … … 518 516 void RenderImage::updateAltText() 519 517 { 520 if (element()-> id() == ID_INPUT)518 if (element()->hasTagName(HTMLNames::input())) 521 519 alt = static_cast<HTMLInputElementImpl*>(element())->altText(); 522 else if (element()-> id() == ID_IMG)520 else if (element()->hasTagName(HTMLNames::img())) 523 521 alt = static_cast<HTMLImageElementImpl*>(element())->altText(); 524 522 } -
trunk/WebCore/khtml/rendering/render_image.h
r8687 r9639 24 24 #define RENDER_IMAGE_H 25 25 26 #include "html/dtd.h"27 26 #include "html/html_elementimpl.h" 28 27 #include "rendering/render_replaced.h" -
trunk/WebCore/khtml/rendering/render_layer.cpp
r9155 r9639 50 50 #include "xml/dom_docimpl.h" 51 51 #include "xml/dom2_eventsimpl.h" 52 #include "misc/htmltags.h"53 52 #include "html/html_blockimpl.h" 54 53 … … 1468 1467 int result = m_layer->renderer()->style()->marqueeSpeed(); 1469 1468 DOM::NodeImpl* elt = m_layer->renderer()->element(); 1470 if (elt && elt-> id() == ID_MARQUEE) {1469 if (elt && elt->hasTagName(HTMLNames::marquee())) { 1471 1470 HTMLMarqueeElementImpl* marqueeElt = static_cast<HTMLMarqueeElementImpl*>(elt); 1472 1471 result = kMax(result, marqueeElt->minimumDelay()); -
trunk/WebCore/khtml/rendering/render_line.cpp
r9595 r9639 38 38 39 39 #include "khtmlview.h" 40 #include "htmltags.h"41 40 42 41 using namespace DOM; -
trunk/WebCore/khtml/rendering/render_list.cpp
r9595 r9639 27 27 28 28 #include "xml/dom_docimpl.h" 29 #include "misc/htmltags.h" 29 30 #include "htmlnames.h" 30 31 31 32 #include <qpainter.h> … … 38 39 39 40 using DOM::DocumentImpl; 41 using DOM::HTMLNames; 40 42 using namespace khtml; 41 43 … … 214 216 215 217 if (currChild->style()->htmlHacks() && currChild->element() && 216 (currChild->element()-> id() == ID_UL || currChild->element()->id() == ID_OL))218 (currChild->element()->hasTagName(HTMLNames::ul())|| currChild->element()->hasTagName(HTMLNames::ol()))) 217 219 break; 218 220 -
trunk/WebCore/khtml/rendering/render_object.cpp
r9595 r9639 44 44 #include "render_block.h" 45 45 #include "render_flexbox.h" 46 #include "htmlnames.h" 46 47 47 48 #if APPLE_CHANGES … … 176 177 bool RenderObject::isBody() const 177 178 { 178 return element() && element()->renderer() == this && element()-> id() == ID_BODY;179 return element() && element()->renderer() == this && element()->hasTagName(HTMLNames::body()); 179 180 } 180 181 181 182 bool RenderObject::isHR() const 182 183 { 183 return element() && element()-> id() == ID_HR;184 return element() && element()->hasTagName(HTMLNames::hr()); 184 185 } 185 186 186 187 bool RenderObject::isHTMLMarquee() const 187 188 { 188 return element() && element()->renderer() == this && element()-> id() == ID_MARQUEE;189 return element() && element()->renderer() == this && element()->hasTagName(HTMLNames::marquee()); 189 190 } 190 191 … … 738 739 if (isFloating() || (isCompact() && isInline()) || 739 740 (isInlineBlockOrInlineTable() && !isHTMLMarquee()) || 740 (element() && (element()-> id() == ID_BUTTON || element()->id() == ID_LEGEND)))741 (element() && (element()->hasTagName(HTMLNames::button()) || element()->hasTagName(HTMLNames::legend())))) 741 742 return true; 742 743 … … 1327 1328 if (element() && element()->isLink()) ts << "anchor "; 1328 1329 if (element() && element()->focused()) ts << "focus "; 1329 if (element()) ts << " <" << getTagName(element()->id()).string() << ">";1330 if (element()) ts << " <" << element()->localName().string() << ">"; 1330 1331 ts << " (" << xPos() << "," << yPos() << "," << width() << "," << height() << ")" 1331 1332 << (isTableCell() ? … … 1557 1558 // the canvas. Just dirty the entire canvas when our style changes substantially. 1558 1559 if (d >= RenderStyle::Repaint && element() && 1559 (element()-> id() == ID_HTML || element()->id() == ID_BODY))1560 (element()->hasTagName(HTMLNames::html()) || element()->hasTagName(HTMLNames::body()))) 1560 1561 canvas()->repaint(); 1561 1562 else if (m_parent && !isText()) { … … 2189 2190 curr = curr->continuation(); 2190 2191 } while (curr && decorations && (!quirksMode || !curr->element() || 2191 ( curr->element()->id() != ID_A && curr->element()->id() != ID_FONT)));2192 (!curr->element()->hasTagName(HTMLNames::a()) && !curr->element()->hasTagName(HTMLNames::font())))); 2192 2193 2193 2194 // If we bailed out, use the element we bailed out at (typically a <font> or <a> element). … … 2323 2324 2324 2325 if (image && image->pixmap_size() == image->valid_rect().size() && parent()) { 2325 if (canvas() && element() && (element()-> id() == ID_HTML || element()->id() == ID_BODY))2326 if (canvas() && element() && (element()->hasTagName(HTMLNames::html()) || element()->hasTagName(HTMLNames::body()))) 2326 2327 canvas()->repaint(); // repaint the entire canvas since the background gets propagated up 2327 2328 else -
trunk/WebCore/khtml/rendering/render_style.cpp
r9356 r9639 608 608 RenderStyle* RenderStyle::getPseudoStyle(PseudoId pid) 609 609 { 610 if (!pseudoStyle) 611 return 0; 612 610 613 RenderStyle *ps = 0; 611 614 if (noninherited_flags._styleType==NOPSEUDO) { -
trunk/WebCore/khtml/rendering/render_style.h
r9165 r9639 300 300 public: 301 301 StyleSurroundData(); 302 303 StyleSurroundData(const StyleSurroundData& o ); 302 StyleSurroundData(const StyleSurroundData& o); 303 304 MAIN_THREAD_ALLOCATED; 305 304 306 bool operator==(const StyleSurroundData& o) const; 305 307 bool operator!=(const StyleSurroundData& o) const { … … 321 323 public: 322 324 StyleBoxData(); 323 324 StyleBoxData(const StyleBoxData& o ); 325 325 StyleBoxData(const StyleBoxData& o); 326 327 MAIN_THREAD_ALLOCATED; 326 328 327 329 // copy and assignment … … 400 402 public: 401 403 StyleVisualData(); 402 403 404 ~StyleVisualData(); 404 405 405 StyleVisualData(const StyleVisualData& o ); 406 407 MAIN_THREAD_ALLOCATED; 406 408 407 409 bool operator==( const StyleVisualData &o ) const { … … 522 524 StyleBackgroundData(const StyleBackgroundData& o ); 523 525 526 MAIN_THREAD_ALLOCATED; 527 524 528 bool operator==(const StyleBackgroundData& o) const; 525 529 bool operator!=(const StyleBackgroundData &o) const { … … 544 548 StyleMarqueeData(const StyleMarqueeData& o); 545 549 550 MAIN_THREAD_ALLOCATED; 551 546 552 bool operator==(const StyleMarqueeData& o) const; 547 553 bool operator!=(const StyleMarqueeData& o) const { … … 571 577 StyleFlexibleBoxData(); 572 578 StyleFlexibleBoxData(const StyleFlexibleBoxData& o); 579 580 MAIN_THREAD_ALLOCATED; 573 581 574 582 bool operator==(const StyleFlexibleBoxData& o) const; … … 677 685 ~StyleCSS3NonInheritedData(); 678 686 StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData& o); 687 688 MAIN_THREAD_ALLOCATED; 679 689 680 690 #ifndef KHTML_NO_XBL … … 716 726 StyleCSS3InheritedData(const StyleCSS3InheritedData& o); 717 727 728 MAIN_THREAD_ALLOCATED; 729 718 730 bool operator==(const StyleCSS3InheritedData& o) const; 719 731 bool operator!=(const StyleCSS3InheritedData &o) const { … … 770 782 StyleInheritedData(const StyleInheritedData& o ); 771 783 784 MAIN_THREAD_ALLOCATED; 785 772 786 bool operator==(const StyleInheritedData& o) const; 773 787 bool operator != ( const StyleInheritedData &o ) const { -
trunk/WebCore/khtml/rendering/render_table.cpp
r9157 r9639 32 32 #include "rendering/table_layout.h" 33 33 #include "html/html_tableimpl.h" 34 #include "misc/htmltags.h"35 34 #include "misc/htmlattrs.h" 35 #include "htmlnames.h" 36 36 #include "xml/dom_docimpl.h" 37 37 … … 113 113 RenderObject *o = child; 114 114 115 if (child->element() && child->element()-> id() == ID_FORM) {115 if (child->element() && child->element()->hasTagName(HTMLNames::form())) { 116 116 RenderContainer::addChild(child,beforeChild); 117 117 return; … … 263 263 RenderObject *child = firstChild(); 264 264 while( child ) { 265 if ( child->needsLayout() && !(child->element() && child->element()-> id() == ID_FORM))265 if ( child->needsLayout() && !(child->element() && child->element()->hasTagName(HTMLNames::form()))) 266 266 child->layout(); 267 267 if ( child->isTableSection() ) { … … 850 850 RenderObject *row = child; 851 851 852 if (child->element() && child->element()-> id() == ID_FORM) {852 if (child->element() && child->element()->hasTagName(HTMLNames::form())) { 853 853 RenderContainer::addChild(child,beforeChild); 854 854 return; … … 1496 1496 (beforeChild ? beforeChild->renderName() : "0") << " )" << endl; 1497 1497 #endif 1498 if (child->element() && child->element()-> id() == ID_FORM) {1498 if (child->element() && child->element()->hasTagName(HTMLNames::form())) { 1499 1499 RenderContainer::addChild(child,beforeChild); 1500 1500 return; … … 1607 1607 int oldCSpan = cSpan; 1608 1608 DOM::NodeImpl* node = element(); 1609 if (node && (node-> id() == ID_TD || node->id() == ID_TH)) {1609 if (node && (node->hasTagName(HTMLNames::td()) || node->hasTagName(HTMLNames::th()))) { 1610 1610 DOM::HTMLTableCellElementImpl *tc = static_cast<DOM::HTMLTableCellElementImpl *>(node); 1611 1611 cSpan = tc->colSpan(); … … 2291 2291 int oldSpan = _span; 2292 2292 DOM::NodeImpl *node = element(); 2293 if (node && (node-> id() == ID_COL || node->id() == ID_COLGROUP)) {2293 if (node && (node->hasTagName(HTMLNames::col()) || node->hasTagName(HTMLNames::colgroup()))) { 2294 2294 DOM::HTMLTableColElementImpl *tc = static_cast<DOM::HTMLTableColElementImpl *>(node); 2295 2295 _span = tc->span(); -
trunk/WebCore/khtml/xml/dom2_rangeimpl.cpp
r9169 r9639 30 30 #include "dom_xmlimpl.h" 31 31 #include "html/html_elementimpl.h" 32 #include "misc/htmltags.h"33 32 #include "editing/markup.h" 34 33 #include "editing/visible_position.h" -
trunk/WebCore/khtml/xml/dom2_traversalimpl.cpp
r9153 r9639 27 27 #include "xml/dom_docimpl.h" 28 28 29 #include "htmltags.h"30 31 29 namespace DOM { 32 30 -
trunk/WebCore/khtml/xml/dom_atomicstring.cpp
r9616 r9639 27 27 // runs at init time. 28 28 29 #if APPLE_CHANGES30 #define AVOID_STATIC_CONSTRUCTORS 131 #endif32 33 #if AVOID_STATIC_CONSTRUCTORS34 29 #define KHTML_ATOMICSTRING_HIDE_GLOBALS 1 35 #endif36 30 37 31 #include "dom_atomicstring.h" … … 52 46 inline bool equal(DOMStringImpl* const& r, const char* const& s) 53 47 { 54 if (!r && !s) return true;55 if (!r || !s) return false;56 57 48 int length = r->l; 58 49 const QChar *d = r->s; … … 101 92 inline bool equal(DOMStringImpl* const& str, const QCharBuffer &buf) 102 93 { 103 const uint32_t *strChars = reinterpret_cast<const uint32_t *>(str->s);104 const uint32_t *bufChars = reinterpret_cast<const uint32_t *>(buf.s);105 106 if (!strChars && !bufChars) return true;107 if (!strChars || !bufChars) return false;108 109 94 uint strLength = str->l; 110 95 uint bufLength = buf.length; … … 112 97 return false; 113 98 99 const uint32_t *strChars = reinterpret_cast<const uint32_t *>(str->s); 100 const uint32_t *bufChars = reinterpret_cast<const uint32_t *>(buf.s); 114 101 115 102 uint halfLength = strLength >> 1; … … 166 153 } 167 154 168 // Global constants for property name strings. 169 170 #if !AVOID_STATIC_CONSTRUCTORS 171 // Define an AtomicString in the normal way. 172 #define DEFINE_GLOBAL(name, string) extern const AtomicString name ## Atom(string); 173 174 extern const AtomicString nullAtom; 175 extern const AtomicString emptyAtom; 176 #else 177 // Define an AtomicString-sized array of pointers to avoid static initialization. 178 // Use an array of pointers instead of an array of char in case there is some alignment issue. 179 #define DEFINE_GLOBAL(name, string) \ 180 void * name ## Atom[(sizeof(AtomicString) + sizeof(void *) - 1) / sizeof(void *)]; 181 182 DEFINE_GLOBAL(null, ignored) 183 DEFINE_GLOBAL(empty, ignored) 184 #endif 185 186 #define CALL_DEFINE_GLOBAL(name) DEFINE_GLOBAL(name, #name) 187 KHTML_ATOMICSTRING_EACH_GLOBAL(CALL_DEFINE_GLOBAL) 155 // Define an AtomicString-sized array of pointers to avoid static initialization. 156 // Use an array of pointers instead of an array of char in case there is some alignment issue. 157 #define DEFINE_GLOBAL(name) \ 158 void* name ## Atom[(sizeof(AtomicString) + sizeof(void*) - 1) / sizeof(void*)]; 159 160 DEFINE_GLOBAL(null) 161 DEFINE_GLOBAL(empty) 162 DEFINE_GLOBAL(text) 163 DEFINE_GLOBAL(comment) 164 DEFINE_GLOBAL(star) 188 165 189 166 void AtomicString::init() 190 167 { 191 #if AVOID_STATIC_CONSTRUCTORS192 168 static bool initialized; 193 169 if (!initialized) { … … 195 171 new (&nullAtom) AtomicString; 196 172 new (&emptyAtom) AtomicString(""); 197 198 #define PLACEMENT_NEW_GLOBAL(name, string) new (&name ## PropertyName) AtomicString(string);199 #define CALL_PLACEMENT_NEW_GLOBAL(name) PLACEMENT_NEW_GLOBAL(name, #name)200 KHTML_ATOMICSTRING_EACH_GLOBAL(CALL_PLACEMENT_NEW_GLOBAL) 173 new (&textAtom) AtomicString("#text"); 174 new (&commentAtom) AtomicString("#comment"); 175 new (&starAtom) AtomicString("*"); 176 201 177 initialized = true; 202 178 } 203 #endif204 179 } 205 180 -
trunk/WebCore/khtml/xml/dom_atomicstring.h
r9509 r9639 56 56 khtml::Length* toLengthArray(int& len) const { return m_string.toLengthArray(len); } 57 57 khtml::Length* toCoordsArray(int& len) const { return m_string.toCoordsArray(len); } 58 58 59 59 bool isNull() const { return m_string.isNull(); } 60 60 bool isEmpty() const { return m_string.isEmpty(); } … … 110 110 // List of property names, passed to a macro so we can do set them up various 111 111 // ways without repeating the list. 112 #define KHTML_ATOMICSTRING_EACH_GLOBAL(macro)113 112 114 // Define external global variables for all property names above (and one more).113 // Define external global variables for the commonly used atomic strings. 115 114 #if !KHTML_ATOMICSTRING_HIDE_GLOBALS 116 115 extern const AtomicString nullAtom; 117 116 extern const AtomicString emptyAtom; 118 #define KHTML_ATOMICSTRING_DECLARE_GLOBAL(name) extern const AtomicString name ## PropertyName; 119 KHTML_ATOMICSTRING_EACH_GLOBAL(KHTML_ATOMICSTRING_DECLARE_GLOBAL) 120 KHTML_ATOMICSTRING_DECLARE_GLOBAL(specialPrototype) 121 #undef KHTML_ATOMICSTRING_DECLARE_GLOBAL 117 extern const AtomicString textAtom; 118 extern const AtomicString commentAtom; 119 extern const AtomicString starAtom; 122 120 #endif 123 121 -
trunk/WebCore/khtml/xml/dom_docimpl.cpp
r9613 r9639 35 35 #include "xml/xml_tokenizer.h" 36 36 37 #include "xml_namespace_table.h"38 39 37 #include "css/csshelper.h" 40 38 #include "css/cssstyleselector.h" … … 66 64 #include "khtmlpart_p.h" 67 65 68 #include "html/html_baseimpl.h" 69 #include "html/html_blockimpl.h" 70 #include "html/html_canvasimpl.h" 66 // FIXME: We want to cut the remaining HTML dependencies so that we don't need to include these files. 71 67 #include "html/html_documentimpl.h" 72 #include "html/html_formimpl.h"73 68 #include "html/html_headimpl.h" 74 69 #include "html/html_imageimpl.h" 75 #include "html/html_listimpl.h" 76 #include "html/html_miscimpl.h" 77 #include "html/html_tableimpl.h" 78 #include "html/html_objectimpl.h" 70 #include "htmlfactory.h" 79 71 80 72 #include "cssvalues.h" … … 505 497 } 506 498 507 ElementImpl *DocumentImpl::createElement( const DOMString &name, int &exceptioncode)508 { 509 return new XMLElementImpl( document, name.implementation());499 ElementImpl *DocumentImpl::createElement(const DOMString &name, int &exceptionCode) 500 { 501 return createElementNS(emptyAtom, name, exceptionCode); 510 502 } 511 503 … … 574 566 case Node::ELEMENT_NODE: { 575 567 ElementImpl *oldElement = static_cast<ElementImpl *>(importedNode); 576 DocumentImpl *oldDoc = oldElement->getDocument(); 577 static DOMString HTMLNamespace(XHTML_NAMESPACE); 578 DOMString elementNamespace = oldElement->isHTMLElement() ? HTMLNamespace : oldElement->namespaceURI(); 579 ElementImpl *newElement = createElementNS(elementNamespace.implementation(), oldElement->tagName(), exceptioncode); 568 // FIXME: Prefix is lost. Is that right? 569 ElementImpl *newElement = createElementNS(oldElement->namespaceURI(), oldElement->localName(), exceptioncode); 580 570 if (exceptioncode != 0) 581 571 return 0; … … 598 588 } 599 589 600 NodeImpl::Id nodeId = attrId(oldDoc->namespaceURI(attr->attrImpl()->id()), localName.implementation(), false /* allocate */); 590 // FIXME: Lose the namespace here for now. This code will change soon anyway. 591 NodeImpl::Id nodeId = attrId(0, localName.implementation(), false /* allocate */); 601 592 newElement->setAttribute(nodeId, value.implementation(), exceptioncode); 602 593 if (exceptioncode != 0) { … … 637 628 ElementImpl *DocumentImpl::createElementNS( const DOMString &_namespaceURI, const DOMString &_qualifiedName, int &exceptioncode) 638 629 { 639 ElementImpl *e = 0; 640 QString qName = _qualifiedName.string(); 641 int colonPos = qName.find(':',0); 642 643 if (_namespaceURI == XHTML_NAMESPACE) { 644 // User requested an element in the XHTML namespace - this means we create a specific element 645 // (elements not in this namespace are treated as normal XML elements) 646 e = createHTMLElement(qName.mid(colonPos+1), exceptioncode); 647 if (exceptioncode) 630 // Split the name. 631 int exceptionCode = 0; 632 ElementImpl* e = 0; 633 DOMString prefix, localName; 634 int colonPos = _qualifiedName.find(':'); 635 if (colonPos >= 0) { 636 prefix = _qualifiedName.substring(0, colonPos); 637 localName = _qualifiedName.substring(colonPos+1, _qualifiedName.length() - colonPos); 638 } 639 else 640 localName = _qualifiedName; 641 642 // FIXME: Use registered namespaces and look up in a hash to find the right factory. 643 if (_namespaceURI == HTMLNames::xhtmlNamespaceURI()) { 644 // FIXME: Really should only be done from the public DOM API. Internal callers know the name is valid. 645 if (!isValidName(localName)) { 646 exceptioncode = DOMException::INVALID_CHARACTER_ERR; 648 647 return 0; 649 if (e && colonPos >= 0) { 650 e->setPrefix(qName.left(colonPos), exceptioncode); 651 if (exceptioncode) { 652 delete e; 648 } 649 e = HTMLElementFactory::createHTMLElement(AtomicString(localName), this, 0, false); 650 if (e && !prefix.isNull()) { 651 e->setPrefix(AtomicString(prefix), exceptionCode); 652 if (exceptionCode) 653 653 return 0; 654 } 655 } 656 } 657 654 } 655 } 656 658 657 if (!e) 659 e = new XMLElementImpl( document, _qualifiedName.implementation(), _namespaceURI.implementation());660 658 e = new ElementImpl(QualifiedName(AtomicString(prefix), AtomicString(localName), AtomicString(_namespaceURI)), document); 659 661 660 return e; 662 661 } … … 812 811 } 813 812 814 ElementImpl *DocumentImpl::createHTMLElement( const DOMString &name, int &exceptioncode )815 {816 if (!isValidName(name)) {817 exceptioncode = DOMException::INVALID_CHARACTER_ERR;818 return 0;819 }820 return createHTMLElement(tagId(0, name.implementation(), false));821 }822 823 ElementImpl *DocumentImpl::createHTMLElement(unsigned short tagID)824 {825 switch (tagID)826 {827 case ID_HTML:828 return new HTMLHtmlElementImpl(docPtr());829 case ID_HEAD:830 return new HTMLHeadElementImpl(docPtr());831 case ID_BODY:832 return new HTMLBodyElementImpl(docPtr());833 834 // head elements835 case ID_BASE:836 return new HTMLBaseElementImpl(docPtr());837 case ID_LINK:838 return new HTMLLinkElementImpl(docPtr());839 case ID_META:840 return new HTMLMetaElementImpl(docPtr());841 case ID_STYLE:842 return new HTMLStyleElementImpl(docPtr());843 case ID_TITLE:844 return new HTMLTitleElementImpl(docPtr());845 846 // frames847 case ID_FRAME:848 return new HTMLFrameElementImpl(docPtr());849 case ID_FRAMESET:850 return new HTMLFrameSetElementImpl(docPtr());851 case ID_IFRAME:852 return new HTMLIFrameElementImpl(docPtr());853 854 // form elements855 // ### FIXME: we need a way to set form dependency after we have made the form elements856 case ID_FORM:857 return new HTMLFormElementImpl(docPtr());858 case ID_BUTTON:859 return new HTMLButtonElementImpl(docPtr());860 case ID_FIELDSET:861 return new HTMLFieldSetElementImpl(docPtr());862 case ID_INPUT:863 return new HTMLInputElementImpl(docPtr());864 case ID_ISINDEX:865 return new HTMLIsIndexElementImpl(docPtr());866 case ID_LABEL:867 return new HTMLLabelElementImpl(docPtr());868 case ID_LEGEND:869 return new HTMLLegendElementImpl(docPtr());870 case ID_OPTGROUP:871 return new HTMLOptGroupElementImpl(docPtr());872 case ID_OPTION:873 return new HTMLOptionElementImpl(docPtr());874 case ID_SELECT:875 return new HTMLSelectElementImpl(docPtr());876 case ID_TEXTAREA:877 return new HTMLTextAreaElementImpl(docPtr());878 879 // lists880 case ID_DL:881 return new HTMLDListElementImpl(docPtr());882 case ID_DD:883 return new HTMLGenericElementImpl(docPtr(), tagID);884 case ID_DT:885 return new HTMLGenericElementImpl(docPtr(), tagID);886 case ID_UL:887 return new HTMLUListElementImpl(docPtr());888 case ID_OL:889 return new HTMLOListElementImpl(docPtr());890 case ID_DIR:891 return new HTMLDirectoryElementImpl(docPtr());892 case ID_MENU:893 return new HTMLMenuElementImpl(docPtr());894 case ID_LI:895 return new HTMLLIElementImpl(docPtr());896 897 // formatting elements (block)898 case ID_BLOCKQUOTE:899 return new HTMLBlockquoteElementImpl(docPtr());900 case ID_DIV:901 return new HTMLDivElementImpl(docPtr());902 case ID_H1:903 case ID_H2:904 case ID_H3:905 case ID_H4:906 case ID_H5:907 case ID_H6:908 return new HTMLHeadingElementImpl(docPtr(), tagID);909 case ID_HR:910 return new HTMLHRElementImpl(docPtr());911 case ID_P:912 return new HTMLParagraphElementImpl(docPtr());913 case ID_PRE:914 case ID_XMP:915 case ID_PLAINTEXT:916 return new HTMLPreElementImpl(docPtr(), tagID);917 case ID_LAYER:918 return new HTMLLayerElementImpl(docPtr());919 920 // font stuff921 case ID_BASEFONT:922 return new HTMLBaseFontElementImpl(docPtr());923 case ID_FONT:924 return new HTMLFontElementImpl(docPtr());925 926 // ins/del927 case ID_DEL:928 case ID_INS:929 return new HTMLModElementImpl(docPtr(), tagID);930 931 // anchor932 case ID_A:933 return new HTMLAnchorElementImpl(docPtr());934 935 // images936 case ID_IMG:937 return new HTMLImageElementImpl(docPtr());938 case ID_MAP:939 return new HTMLMapElementImpl(docPtr());940 case ID_AREA:941 return new HTMLAreaElementImpl(docPtr());942 case ID_CANVAS:943 return new HTMLCanvasElementImpl(docPtr());944 945 // objects, applets and scripts946 case ID_APPLET:947 return new HTMLAppletElementImpl(docPtr());948 case ID_EMBED:949 return new HTMLEmbedElementImpl(docPtr());950 case ID_OBJECT:951 return new HTMLObjectElementImpl(docPtr());952 case ID_PARAM:953 return new HTMLParamElementImpl(docPtr());954 case ID_SCRIPT:955 return new HTMLScriptElementImpl(docPtr());956 957 // tables958 case ID_TABLE:959 return new HTMLTableElementImpl(docPtr());960 case ID_CAPTION:961 return new HTMLTableCaptionElementImpl(docPtr());962 case ID_COLGROUP:963 case ID_COL:964 return new HTMLTableColElementImpl(docPtr(), tagID);965 case ID_TR:966 return new HTMLTableRowElementImpl(docPtr());967 case ID_TD:968 case ID_TH:969 return new HTMLTableCellElementImpl(docPtr(), tagID);970 case ID_THEAD:971 case ID_TBODY:972 case ID_TFOOT:973 return new HTMLTableSectionElementImpl(docPtr(), tagID, false);974 975 // inline elements976 case ID_BR:977 return new HTMLBRElementImpl(docPtr());978 case ID_Q:979 return new HTMLQuoteElementImpl(docPtr());980 981 case ID_MARQUEE:982 return new HTMLMarqueeElementImpl(docPtr());983 984 // elements with no special representation in the DOM985 986 // block:987 case ID_ADDRESS:988 case ID_CENTER:989 990 // inline991 // %fontstyle992 case ID_TT:993 case ID_U:994 case ID_B:995 case ID_I:996 case ID_S:997 case ID_STRIKE:998 case ID_BIG:999 case ID_SMALL:1000 1001 // %phrase1002 case ID_EM:1003 case ID_STRONG:1004 case ID_DFN:1005 case ID_CODE:1006 case ID_SAMP:1007 case ID_KBD:1008 case ID_VAR:1009 case ID_CITE:1010 case ID_ABBR:1011 case ID_ACRONYM:1012 1013 // %special1014 case ID_SUB:1015 case ID_SUP:1016 case ID_SPAN:1017 case ID_NOBR:1018 case ID_WBR:1019 1020 case ID_BDO:1021 default:1022 return new HTMLGenericElementImpl(docPtr(), tagID);1023 }1024 1025 return 0;1026 }1027 1028 813 QString DocumentImpl::nextState() 1029 814 { … … 1466 1251 NodeImpl* body = 0; 1467 1252 for (NodeImpl* i = de->firstChild(); i; i = i->nextSibling()) { 1468 if (i-> id() == ID_FRAMESET)1253 if (i->hasTagName(HTMLNames::frameset())) 1469 1254 return static_cast<HTMLElementImpl*>(i); 1470 1255 1471 if (i-> id() == ID_BODY)1256 if (i->hasTagName(HTMLNames::body())) 1472 1257 body = i; 1473 1258 } … … 1599 1384 return (renderer() && renderer()->needsLayout() && haveStylesheetsLoaded() && 1600 1385 documentElement() && documentElement()->renderer() && 1601 ( documentElement()->id() != ID_HTML|| body()));1386 (!documentElement()->hasTagName(HTMLNames::html()) || body())); 1602 1387 } 1603 1388 … … 1721 1506 hMode = XHtml; 1722 1507 kdDebug(6020) << " using strict parseMode" << endl; 1723 }1724 1725 // Please see if there`s a possibility to merge that code1726 // with the next function and getElementByID().1727 NodeImpl *DocumentImpl::findElement( Id id )1728 {1729 QPtrStack<NodeImpl> nodeStack;1730 NodeImpl *current = _first;1731 1732 while(1)1733 {1734 if(!current)1735 {1736 if(nodeStack.isEmpty()) break;1737 current = nodeStack.pop();1738 current = current->nextSibling();1739 }1740 else1741 {1742 if(current->id() == id)1743 return current;1744 1745 NodeImpl *child = current->firstChild();1746 if(child)1747 {1748 nodeStack.push(current);1749 current = child;1750 }1751 else1752 {1753 current = current->nextSibling();1754 }1755 }1756 }1757 1758 return 0;1759 1508 } 1760 1509 … … 2139 1888 // First see if it's a HTML attribute name 2140 1889 QConstString n(_name->s, _name->l); 2141 if (!_namespaceURI || !strcasecmp(_namespaceURI, XHTML_NAMESPACE)) {1890 if (!_namespaceURI) { 2142 1891 // we're in HTML namespace if we know the tag. 2143 1892 // xhtml is lower case - case sensitive, easy to implement … … 2153 1902 // now lets find out the namespace 2154 1903 Q_UINT16 ns = noNamespace; 1904 /* FIXME: Just break namespaced attributes for now. Will fix in next stage of QualifiedName conversion. 2155 1905 if (_namespaceURI) { 2156 1906 DOMString nsU(_namespaceURI); … … 2158 1908 if (nsID != -1) 2159 1909 ns = (Q_UINT16)nsID; 2160 } 1910 }*/ 2161 1911 2162 1912 // Look in the m_attrNames array for the name … … 2207 1957 2208 1958 return result; 2209 }2210 2211 NodeImpl::Id DocumentImpl::tagId(DOMStringImpl* _namespaceURI, DOMStringImpl *_name, bool readonly)2212 {2213 if (!_name) return 0;2214 // Each document maintains a mapping of tag name -> id for every tag name encountered2215 // in the document.2216 NodeImpl::Id id = 0;2217 2218 // First see if it's a HTML element name2219 QConstString n(_name->s, _name->l);2220 if (!_namespaceURI || !strcasecmp(_namespaceURI, XHTML_NAMESPACE)) {2221 // we're in HTML namespace if we know the tag.2222 // xhtml is lower case - case sensitive, easy to implement2223 if ( htmlMode() == XHtml && (id = getTagID(n.string().ascii(), _name->l)) )2224 return id;2225 // compatibility: upper case - case insensitive2226 if ( htmlMode() != XHtml && (id = getTagID(n.string().lower().ascii(), _name->l )) )2227 return id;2228 2229 // ok, the fast path didn't work out, we need the full check2230 }2231 2232 // now lets find out the namespace2233 Q_UINT16 ns = noNamespace;2234 if (_namespaceURI) {2235 DOMString nsU(_namespaceURI);2236 int nsID = XmlNamespaceTable::getNamespaceID(nsU, readonly);2237 if (nsID != -1)2238 ns = (Q_UINT16)nsID;2239 }2240 2241 // Look in the m_elementNames array for the name2242 // ### yeah, this is lame. use a dictionary / map instead2243 DOMString nme(n.string());2244 // compatibility mode has to store upper case2245 if (htmlMode() != XHtml) nme = nme.upper();2246 for (id = 0; id < m_elementNameCount; id++)2247 if (DOMString(m_elementNames[id]) == nme)2248 return makeId(ns, ID_LAST_TAG + 1 + id);2249 2250 // unknown2251 if (readonly) return 0;2252 2253 // Name not found in m_elementNames, so let's add it2254 if (m_elementNameCount+1 > m_elementNameAlloc) {2255 m_elementNameAlloc += 100;2256 DOMStringImpl **newNames = new DOMStringImpl* [m_elementNameAlloc];2257 // ### yeah, this is lame. use a dictionary / map instead2258 if (m_elementNames) {2259 unsigned short i;2260 for (i = 0; i < m_elementNameCount; i++)2261 newNames[i] = m_elementNames[i];2262 delete [] m_elementNames;2263 }2264 m_elementNames = newNames;2265 }2266 2267 id = m_elementNameCount++;2268 m_elementNames[id] = nme.implementation();2269 m_elementNames[id]->ref();2270 2271 return makeId(ns, ID_LAST_TAG + 1 + id);2272 }2273 2274 DOMString DocumentImpl::tagName(NodeImpl::Id _id) const2275 {2276 if (localNamePart(_id) > ID_LAST_TAG)2277 return m_elementNames[localNamePart(_id) - (ID_LAST_TAG + 1)];2278 else {2279 // ### put them in a cache2280 if (htmlMode() == XHtml)2281 return getTagName(_id).lower();2282 else2283 return getTagName(_id);2284 }2285 }2286 2287 2288 DOMStringImpl* DocumentImpl::namespaceURI(NodeImpl::Id _id) const2289 {2290 if (_id <= ID_LAST_TAG)2291 return htmlMode() == XHtml ? XmlNamespaceTable::getNamespaceURI(xhtmlNamespace).implementation() : 0;2292 2293 unsigned short ns = _id >> 16;2294 2295 if (!ns) return 0;2296 2297 return XmlNamespaceTable::getNamespaceURI(ns).implementation();2298 1959 } 2299 1960 … … 2421 2082 2422 2083 } 2423 else if (n->isHTMLElement() && (n-> id() == ID_LINK || n->id() == ID_STYLE)) {2424 ElementImpl *e = static_cast<ElementImpl *>(n);2084 else if (n->isHTMLElement() && (n->hasTagName(HTMLNames::link()) || n->hasTagName(HTMLNames::style()))) { 2085 HTMLElementImpl *e = static_cast<HTMLElementImpl *>(n); 2425 2086 QString title = e->getAttribute( ATTR_TITLE ).string(); 2426 2087 bool enabledViaScript = false; 2427 if ( n->id() == ID_LINK) {2088 if (e->hasLocalName(HTMLNames::link())) { 2428 2089 // <LINK> element 2429 2090 HTMLLinkElementImpl* l = static_cast<HTMLLinkElementImpl*>(n); … … 2437 2098 // Get the current preferred styleset. This is the 2438 2099 // set of sheets that will be enabled. 2439 if ( n->id() == ID_LINK)2100 if (e->hasLocalName(HTMLNames::link())) 2440 2101 sheet = static_cast<HTMLLinkElementImpl*>(n)->sheet(); 2441 2102 else … … 2454 2115 // this sheet. 2455 2116 QString rel = e->getAttribute( ATTR_REL ).string(); 2456 if ( n->id() == ID_STYLE|| !rel.contains("alternate"))2117 if (e->hasLocalName(HTMLNames::style()) || !rel.contains("alternate")) 2457 2118 m_preferredStylesheetSet = view()->part()->d->m_sheetUsed = title; 2458 2119 } … … 2473 2134 // For HTML documents, stylesheets are not allowed within/after the <BODY> tag. So we 2474 2135 // can stop searching here. 2475 if (isHTMLDocument() && n-> id() == ID_BODY)2136 if (isHTMLDocument() && n->hasTagName(HTMLNames::body())) 2476 2137 break; 2477 2138 } -
trunk/WebCore/khtml/xml/dom_docimpl.h
r9466 r9639 178 178 DOMImplementationImpl *implementation() const; 179 179 virtual ElementImpl *documentElement() const; 180 virtual ElementImpl *createElement ( const DOMString &tagName, int &exceptioncode);180 virtual ElementImpl *createElement(const DOMString &tagName, int &exceptioncode); 181 181 DocumentFragmentImpl *createDocumentFragment (); 182 182 TextImpl *createTextNode ( const DOMString &data ); … … 189 189 EntityReferenceImpl *createEntityReference ( const DOMString &name ); 190 190 NodeImpl *importNode( NodeImpl *importedNode, bool deep, int &exceptioncode ); 191 virtual ElementImpl *createElementNS ( const DOMString &_namespaceURI, const DOMString &_qualifiedName, int &exceptioncode);191 virtual ElementImpl *createElementNS(const DOMString &_namespaceURI, const DOMString &_qualifiedName, int &exceptioncode); 192 192 ElementImpl *getElementById ( const DOMString &elementId ) const; 193 193 ElementImpl *elementFromPoint ( const int _x, const int _y ) const; … … 218 218 virtual bool isDocumentNode() const { return true; } 219 219 virtual bool isHTMLDocument() const { return false; } 220 221 ElementImpl *createHTMLElement(const DOMString &tagName, int &exceptioncode);222 ElementImpl *createHTMLElement(unsigned short tagID);223 220 224 221 khtml::CSSStyleSelector *styleSelector() { return m_styleSelector; } … … 388 385 void resetActiveLinkColor(); 389 386 390 // internal391 NodeImpl *findElement( Id id );392 393 387 bool prepareMouseEvent( bool readonly, int x, int y, MouseEvent *ev ); 394 388 … … 400 394 // in order to be able to reassign those that are no longer in use 401 395 // (could make problems when it is still kept somewhere around, i.e. styleselector) 402 NodeImpl::Id tagId(DOMStringImpl* _namespaceURI, DOMStringImpl *_name, bool readonly);403 DOMString tagName(NodeImpl::Id _id) const;404 405 396 NodeImpl::Id attrId(DOMStringImpl* _namespaceURI, DOMStringImpl *_name, bool readonly); 406 397 DOMString attrName(NodeImpl::Id _id) const; 407 408 // the namespace uri is mapped to the same id for both409 // tagnames as well as attributes.410 DOMStringImpl* namespaceURI(NodeImpl::Id _id) const;411 398 412 399 StyleSheetListImpl* styleSheets(); -
trunk/WebCore/khtml/xml/dom_elementimpl.cpp
r9158 r9639 34 34 #include "khtml_part.h" 35 35 36 #include "html/dtd.h"37 36 #include "html/htmlparser.h" 38 37 … … 91 90 } 92 91 93 DOMStringAttrImpl::prefix() const92 const AtomicString& AttrImpl::prefix() const 94 93 { 95 94 return m_attribute->prefix(); 96 95 } 97 96 98 void AttrImpl::setPrefix(const DOMString &_prefix, int &exceptioncode )97 void AttrImpl::setPrefix(const AtomicString &_prefix, int &exceptioncode ) 99 98 { 100 99 checkSetPrefix(_prefix, exceptioncode); … … 102 101 return; 103 102 104 m_attribute->setPrefix(_prefix .implementation());103 m_attribute->setPrefix(_prefix); 105 104 } 106 105 … … 203 202 // ------------------------------------------------------------------------- 204 203 205 ElementImpl::ElementImpl( DocumentPtr *doc)206 : ContainerNodeImpl(doc) 204 ElementImpl::ElementImpl(const QualifiedName& qName, DocumentPtr *doc) 205 : ContainerNodeImpl(doc), m_tagName(qName) 207 206 { 208 207 namedAttrMap = 0; 209 m_prefix = 0;210 208 } 211 209 … … 216 214 namedAttrMap->deref(); 217 215 } 218 219 if (m_prefix) 220 m_prefix->deref(); 216 } 217 218 NodeImpl *ElementImpl::cloneNode(bool deep) 219 { 220 int exceptionCode = 0; 221 ElementImpl *clone = getDocument()->createElementNS(namespaceURI(), nodeName(), exceptionCode); 222 assert(!exceptionCode); 223 224 // clone attributes 225 if (namedAttrMap) 226 *clone->attributes() = *namedAttrMap; 227 228 if (deep) 229 cloneChildNodes(clone); 230 231 return clone; 221 232 } 222 233 … … 352 363 { 353 364 updateStyleAttributeIfNeeded(); 354 355 365 return namedAttrMap && namedAttrMap->length() > 0; 356 366 } … … 358 368 DOMString ElementImpl::nodeName() const 359 369 { 360 return tagName(); 361 } 362 363 DOMString ElementImpl::tagName() const 364 { 365 DOMString tn = getDocument()->tagName(id()); 366 367 if (m_prefix) 368 return DOMString(m_prefix) + ":" + tn; 369 370 DOMString tn = m_tagName.localName(); 371 if (m_tagName.hasPrefix()) 372 return DOMString(m_tagName.prefix()) + ":" + tn; 370 373 return tn; 371 374 } 372 375 373 void ElementImpl::setPrefix( const DOMString &_prefix, int &exceptioncode)376 void ElementImpl::setPrefix(const AtomicString &_prefix, int &exceptioncode) 374 377 { 375 378 checkSetPrefix(_prefix, exceptioncode); … … 377 380 return; 378 381 379 if (m_prefix) 380 m_prefix->deref(); 381 m_prefix = _prefix.implementation(); 382 if (m_prefix) 383 m_prefix->ref(); 382 m_tagName.setPrefix(_prefix); 384 383 } 385 384 … … 522 521 } 523 522 524 // DOM Section 1.1.1525 bool ElementImpl::childAllowed( NodeImpl *newChild )526 {527 if (!childTypeAllowed(newChild->nodeType()))528 return false;529 530 // For XML documents, we are non-validating and do not check against a DTD, even for HTML elements.531 if (getDocument()->isHTMLDocument())532 return checkChild(id(), newChild->id(), !getDocument()->inCompatMode());533 return true;534 }535 536 523 bool ElementImpl::childTypeAllowed( unsigned short type ) 537 524 { … … 570 557 DOMString ElementImpl::openTagStartToString() const 571 558 { 572 DOMString result = DOMString("<") + tagName();559 DOMString result = DOMString("<") + nodeName(); 573 560 574 561 NamedAttrMapImpl *attrMap = attributes(true); … … 611 598 612 599 result += "</"; 613 result += tagName();600 result += nodeName(); 614 601 result += ">"; 615 602 } else { … … 760 747 // ------------------------------------------------------------------------- 761 748 762 XMLElementImpl::XMLElementImpl(DocumentPtr *doc, DOMStringImpl *_tagName) 763 : ElementImpl(doc) 764 { 765 m_id = doc->document()->tagId(0 /* no namespace */, _tagName, false /* allocate */); 766 } 767 749 /* 768 750 XMLElementImpl::XMLElementImpl(DocumentPtr *doc, DOMStringImpl *_qualifiedName, DOMStringImpl *_namespaceURI) 769 751 : ElementImpl(doc) … … 781 763 localName->ref(); 782 764 localName->remove(0,colonpos+1); 783 m_id = doc->document()->tagId(_namespaceURI, localName, false /* allocate */);765 m_id = doc->document()->tagId(_namespaceURI, localName, false); 784 766 localName->deref(); 785 m_prefix = _qualifiedName->copy(); 786 m_prefix->ref(); 787 m_prefix->truncate(colonpos); 788 } 789 else { 767 768 // FIXME: This is a temporary situation for stage one of the QualifiedName patch. This is also a really stupid way to 769 // have to handle the prefix. Way too much copying. We should make sure the XML tokenizer has done the split 770 // already into prefix and localName. 771 DOMStringImpl* prefix = _qualifiedName->copy(); 772 prefix->ref(); 773 prefix->truncate(colonpos); 774 m_tagName = QualifiedName(prefix, nullAtom, nullAtom); 775 prefix->deref(); 776 } 777 else 790 778 // no prefix 791 m_id = doc->document()->tagId(_namespaceURI, _qualifiedName, false /* allocate */); 792 m_prefix = 0; 793 } 794 } 795 796 XMLElementImpl::~XMLElementImpl() 797 { 798 } 799 800 DOMString XMLElementImpl::localName() const 801 { 802 return getDocument()->tagName(m_id); 803 } 804 805 DOMString XMLElementImpl::namespaceURI() const 806 { 807 return getDocument()->namespaceURI(m_id); 808 } 809 810 NodeImpl *XMLElementImpl::cloneNode ( bool deep ) 811 { 812 // ### we lose namespace here FIXME 813 // should pass id around 814 XMLElementImpl *clone = new XMLElementImpl(docPtr(), getDocument()->tagName(m_id).implementation()); 815 clone->m_id = m_id; 816 817 // clone attributes 818 if (namedAttrMap) 819 *clone->attributes(false) = *namedAttrMap; 820 821 if (deep) 822 cloneChildNodes(clone); 823 824 return clone; 825 } 779 m_id = doc->document()->tagId(_namespaceURI, _qualifiedName, false); 780 } 781 782 */ 826 783 827 784 // ------------------------------------------------------------------------- … … 1271 1228 } 1272 1229 1273 StyledElementImpl::StyledElementImpl( DocumentPtr *doc)1274 : ElementImpl( doc)1230 StyledElementImpl::StyledElementImpl(const QualifiedName& name, DocumentPtr *doc) 1231 : ElementImpl(name, doc) 1275 1232 { 1276 1233 m_inlineStyleDecl = 0; -
trunk/WebCore/khtml/xml/dom_elementimpl.h
r9625 r9639 24 24 * 25 25 */ 26 #ifndef _DOM_ELEMENTI mpl_h_27 #define _DOM_ELEMENTI mpl_h_26 #ifndef _DOM_ELEMENTIMPL_h_ 27 #define _DOM_ELEMENTIMPL_h_ 28 28 29 29 #include "dom_nodeimpl.h" … … 31 31 #include "misc/shared.h" 32 32 #include "css/css_valueimpl.h" 33 #include "dom_qname.h" 33 34 34 35 #if APPLE_CHANGES … … 129 130 virtual DOMString nodeName() const; 130 131 virtual unsigned short nodeType() const; 131 virtual DOMStringprefix() const;132 virtual void setPrefix(const DOMString &_prefix, int &exceptioncode );132 virtual const AtomicString& prefix() const; 133 virtual void setPrefix(const AtomicString &_prefix, int &exceptioncode ); 133 134 134 135 virtual DOMString nodeValue() const; … … 157 158 friend class khtml::CSSStyleSelector; 158 159 public: 159 ElementImpl( DocumentPtr *doc);160 ElementImpl(const QualifiedName& tagName, DocumentPtr *doc); 160 161 ~ElementImpl(); 161 162 … … 187 188 SharedPtr<AttrImpl> removeAttributeNode(AttrImpl *oldAttr, int &exception); 188 189 189 DOMString prefix() const { return m_prefix; }190 void setPrefix(const DOMString &_prefix, int &exceptioncode );191 192 190 virtual CSSStyleDeclarationImpl *style(); 193 191 192 virtual const QualifiedName& tagName() const { return m_tagName; } 193 virtual bool hasTagName(const QualifiedName& tagName) const { return m_tagName.matches(tagName); } 194 195 // A fast function for checking the local name against another atomic string. 196 bool hasLocalName(const AtomicString& other) const { return m_tagName.localName() == other; } 197 bool hasLocalName(const QualifiedName& other) const { return m_tagName.localName() == other.localName(); } 198 199 virtual const AtomicString& localName() const { return m_tagName.localName(); } 200 virtual const AtomicString& prefix() const { return m_tagName.prefix(); } 201 virtual void setPrefix(const AtomicString &_prefix, int &exceptioncode); 202 virtual const AtomicString& namespaceURI() const { return m_tagName.namespaceURI(); } 203 194 204 // DOM methods overridden from parent classes 195 virtual DOMString tagName() const;196 205 virtual unsigned short nodeType() const; 197 virtual NodeImpl *cloneNode ( bool deep ) = 0;206 virtual NodeImpl *cloneNode(bool deep); 198 207 virtual DOMString nodeName() const; 199 208 virtual bool isElementNode() const { return true; } … … 222 231 223 232 virtual void mouseEventHandler( MouseEvent */*ev*/, bool /*inside*/ ) {}; 224 virtual bool childAllowed( NodeImpl *newChild );225 233 virtual bool childTypeAllowed( unsigned short type ); 226 234 … … 255 263 protected: // member variables 256 264 mutable NamedAttrMapImpl *namedAttrMap; 257 DOMStringImpl *m_prefix; 258 }; 259 260 261 class XMLElementImpl : public ElementImpl 262 { 263 264 public: 265 XMLElementImpl(DocumentPtr *doc, DOMStringImpl *_tagName); 266 XMLElementImpl(DocumentPtr *doc, DOMStringImpl *_qualifiedName, DOMStringImpl *_namespaceURI); 267 ~XMLElementImpl(); 268 269 // DOM methods overridden from parent classes 270 virtual DOMString namespaceURI() const; 271 virtual DOMString localName() const; 272 virtual NodeImpl *cloneNode ( bool deep ); 273 274 // Other methods (not part of DOM) 275 virtual bool isXMLElementNode() const { return true; } 276 virtual Id id() const { return m_id; } 277 278 protected: 279 Id m_id; 265 QualifiedName m_tagName; 280 266 }; 281 267 … … 415 401 { 416 402 public: 417 StyledElementImpl( DocumentPtr *doc);403 StyledElementImpl(const QualifiedName& tagName, DocumentPtr *doc); 418 404 virtual ~StyledElementImpl(); 419 405 -
trunk/WebCore/khtml/xml/dom_nodeimpl.cpp
r9476 r9639 28 28 #include "dom/dom2_events.h" 29 29 #include "misc/htmlattrs.h" 30 #include "misc/htmltags.h"31 30 #include "xml/dom_elementimpl.h" 32 31 #include "xml/dom_textimpl.h" … … 51 50 #include "khtml_part.h" 52 51 53 #include "html/dtd.h" 52 // FIXME: Should not have to include this. Cut the HTML dependency! 53 #include "htmlnames.h" 54 54 55 55 #ifndef KHTML_NO_XBL … … 65 65 #endif 66 66 67 using namespace DOM;68 67 using namespace khtml; 68 69 namespace DOM { 70 /** 71 * NodeList which lists all Nodes in a document with a given tag name 72 */ 73 class TagNodeListImpl : public NodeListImpl 74 { 75 public: 76 TagNodeListImpl(NodeImpl *n, const AtomicString& namespaceURI, const AtomicString& localName); 77 78 // DOM methods overridden from parent classes 79 virtual unsigned long length() const; 80 virtual NodeImpl *item (unsigned long index) const; 81 82 // Other methods (not part of DOM) 83 84 protected: 85 virtual bool nodeMatches(NodeImpl *testNode) const; 86 87 AtomicString m_namespaceURI; 88 AtomicString m_localName; 89 }; 69 90 70 91 NodeImpl::NodeImpl(DocumentPtr *doc) … … 155 176 } 156 177 157 NodeImpl *NodeImpl::lastDescend ent() const178 NodeImpl *NodeImpl::lastDescendant() const 158 179 { 159 180 NodeImpl *n = const_cast<NodeImpl *>(this); … … 240 261 } 241 262 242 DOMStringNodeImpl::prefix() const263 const AtomicString& NodeImpl::prefix() const 243 264 { 244 265 // For nodes other than elements and attributes, the prefix is always null 245 return DOMString();246 } 247 248 void NodeImpl::setPrefix(const DOMString &/*_prefix*/, int &exceptioncode )266 return nullAtom; 267 } 268 269 void NodeImpl::setPrefix(const AtomicString &/*_prefix*/, int &exceptioncode ) 249 270 { 250 271 // The spec says that for nodes other than elements and attributes, prefix is always null. … … 254 275 } 255 276 256 DOMStringNodeImpl::localName() const257 { 258 return DOMString();259 } 260 261 DOMStringNodeImpl::namespaceURI() const262 { 263 return DOMString();277 const AtomicString& NodeImpl::localName() const 278 { 279 return emptyAtom; 280 } 281 282 const AtomicString& NodeImpl::namespaceURI() const 283 { 284 return emptyAtom; 264 285 } 265 286 … … 305 326 getDocument()->setDocumentChanged(true); 306 327 } 307 }308 309 bool NodeImpl::isInline() const310 {311 if (m_render) return m_render->style()->display() == khtml::INLINE;312 return !isElementNode();313 328 } 314 329 … … 1007 1022 } 1008 1023 1009 void NodeImpl::checkSetPrefix(const DOMString &_prefix, int &exceptioncode)1024 void NodeImpl::checkSetPrefix(const AtomicString &_prefix, int &exceptioncode) 1010 1025 { 1011 1026 // Perform error checking as required by spec for setting Node.prefix. Used by 1012 1027 // ElementImpl::setPrefix() and AttrImpl::setPrefix() 1013 1028 1014 #if 0 1015 // FIXME: Add this check (but not in a way that depends on the C++ DOM!) 1016 // INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character. 1017 if (!Element::khtmlValidPrefix(_prefix)) { 1018 exceptioncode = DOMException::INVALID_CHARACTER_ERR; 1019 return; 1020 } 1021 #endif 1022 1029 // FIXME: Implement support for INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character. 1030 1023 1031 // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 1024 1032 if (isReadOnly()) { … … 1027 1035 } 1028 1036 1029 // NAMESPACE_ERR: - Raised if the specified prefix is malformed 1037 // FIXME: Implement NAMESPACE_ERR: - Raised if the specified prefix is malformed 1038 // We have to comment this out, since it's used for attributes and tag names, and we've only 1039 // switched one over. 1040 /* 1030 1041 // - if the namespaceURI of this node is null, 1031 1042 // - if the specified prefix is "xml" and the namespaceURI of this node is different from … … 1034 1045 // the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/", 1035 1046 // - or if this node is an attribute and the qualifiedName of this node is "xmlns" [Namespaces]. 1036 if ( 1037 #if 0 1038 // FIXME: Add this check (but not in a way that depends on the C++ DOM!) 1039 Element::khtmlMalformedPrefix(_prefix) || 1040 #endif 1041 (namespacePart(id()) == noNamespace && id() > ID_LAST_TAG) || 1047 if ((namespacePart(id()) == noNamespace && id() > ID_LAST_TAG) || 1042 1048 (_prefix == "xml" && DOMString(getDocument()->namespaceURI(id())) != "http://www.w3.org/XML/1998/namespace")) { 1043 1049 exceptioncode = DOMException::NAMESPACE_ERR; 1044 1050 return; 1045 } 1051 }*/ 1046 1052 } 1047 1053 … … 1284 1290 } 1285 1291 1292 // FIXME: This code is used by editing. Seems like it could move over there and not pollute NodeImpl. 1286 1293 bool NodeImpl::isAtomicNode() const 1287 1294 { 1288 return !hasChildNodes() || ( id() == ID_OBJECT && renderer() && renderer()->isReplaced());1295 return !hasChildNodes() || (renderer() && renderer()->isWidget()); 1289 1296 } 1290 1297 … … 1403 1410 } 1404 1411 1412 // FIXME: Shouldn't these functions be in the editing code? Code that asks questions about HTML in the core DOM class 1413 // is obviously misplaced. 1405 1414 // method for editing madness, which allows BR,1 as a position, though that is incorrect 1406 1415 long NodeImpl::maxDeepOffset() const … … 1409 1418 return static_cast<const TextImpl*>(this)->length(); 1410 1419 1411 if ( id() == ID_BR|| (renderer() && renderer()->isReplaced()))1420 if (hasTagName(HTMLNames::br()) || (renderer() && renderer()->isReplaced())) 1412 1421 return 1; 1413 1422 … … 1465 1474 if (!n) 1466 1475 break; 1467 if (n->isBlockFlowOrTable() || n-> id() == ID_BODY)1476 if (n->isBlockFlowOrTable() || n->hasTagName(HTMLNames::body())) 1468 1477 return static_cast<ElementImpl *>(n); 1469 1478 } … … 1481 1490 if (!n) 1482 1491 break; 1483 if (n->isBlockFlow() || n-> id() == ID_BODY)1492 if (n->isBlockFlow() || n->hasTagName(HTMLNames::body())) 1484 1493 return static_cast<ElementImpl *>(n); 1485 1494 } … … 1494 1503 while (1) { 1495 1504 p = n->parentNode(); 1496 if (!p || p->isBlockFlow() || p-> id() == ID_BODY)1505 if (!p || p->isBlockFlow() || p->hasTagName(HTMLNames::body())) 1497 1506 return static_cast<ElementImpl *>(n); 1498 1507 // Also stop if any previous sibling is a block … … 1513 1522 1514 1523 NodeImpl *n = const_cast<NodeImpl *>(this); 1515 if (n-> id() == ID_BODY)1524 if (n->hasTagName(HTMLNames::body())) 1516 1525 return static_cast<ElementImpl *>(n); 1517 1526 … … 1521 1530 if (!n || !n->isContentEditable()) 1522 1531 break; 1523 if (n-> id() == ID_BODY) {1532 if (n->hasTagName(HTMLNames::body())) { 1524 1533 result = n; 1525 1534 break; … … 1541 1550 } 1542 1551 1552 // FIXME: End of obviously misplaced HTML editing functions. Try to move these out of NodeImpl. 1553 1543 1554 void NodeImpl::addEventListener(const DOMString &type, EventListener *listener, bool useCapture) 1544 1555 { … … 1551 1562 } 1552 1563 1553 SharedPtr<NodeListImpl> NodeImpl::getElementsByTagNameNS ( const DOMString &namespaceURI, const DOMString &localName ) 1554 { 1555 if (localName.isNull()) 1556 return SharedPtr<NodeListImpl>(); 1557 1558 Id idMask = namespaceMask | localNameMask; 1559 if (localName[0] == '*') 1560 idMask &= ~localNameMask; 1561 if (namespaceURI.isNull() || namespaceURI[0] == '*') 1562 idMask &= ~namespaceMask; 1563 1564 Id id = 0; // 0 means "all items" 1565 if ((idMask & localNameMask) || !namespaceURI.isNull()) { // not getElementsByTagName("*") 1566 id = getDocument()->tagId(namespaceURI.implementation(), localName.implementation(), true); 1567 if ( !id ) // not found -> we want to return an empty list, not "all items" 1568 id = (Id)-1; // HACK. HEAD has a cleaner implementation of TagNodeListImpl it seems. 1569 } 1570 1571 return SharedPtr<NodeListImpl>(new TagNodeListImpl(this, id, idMask)); 1564 SharedPtr<NodeListImpl> NodeImpl::getElementsByTagNameNS(const DOMString &namespaceURI, const DOMString &localName) 1565 { 1566 if (namespaceURI.isNull() || localName.isNull()) 1567 return SharedPtr<NodeListImpl>(); // FIXME: Who cares about this additional check? 1568 1569 DOMString name = localName; 1570 if (getDocument()->isHTMLDocument()) 1571 name = localName.lower(); 1572 return SharedPtr<NodeListImpl>(new TagNodeListImpl(this, AtomicString(namespaceURI), AtomicString(name))); 1572 1573 } 1573 1574 … … 1592 1593 return 0; 1593 1594 } 1594 1595 #if APPLE_CHANGES1596 NodeImpl::Id NodeImpl::identifier() const1597 {1598 return id();1599 }1600 #endif1601 1595 1602 1596 #ifndef NDEBUG … … 1639 1633 NodeImpl *rootNode; 1640 1634 NodeImpl *node = (NodeImpl *)this; 1641 while (node->parentNode() != NULL && node->id() != ID_BODY)1635 while (node->parentNode() && !node->hasTagName(HTMLNames::body())) 1642 1636 node = node->parentNode(); 1643 1637 rootNode = node; … … 2095 2089 2096 2090 // short check for consistency with DTD 2097 if(!isXMLElementNode() && !newChild->isXMLElementNode() && !childAllowed(newChild)) 2098 { 2099 //kdDebug( 6020 ) << "AddChild failed! id=" << id() << ", child->id=" << newChild->id() << endl; 2091 if (getDocument()->isHTMLDocument() && !childAllowed(newChild)) 2100 2092 return 0; 2101 }2102 2093 2103 2094 // just add it... … … 2537 2528 } 2538 2529 2539 TagNodeListImpl::TagNodeListImpl(NodeImpl *n, NodeImpl::Id _id, NodeImpl::Id _idMask)2530 TagNodeListImpl::TagNodeListImpl(NodeImpl *n, const AtomicString& namespaceURI, const AtomicString& localName) 2540 2531 : NodeListImpl(n), 2541 m_ id(_id & _idMask),2542 m_ idMask(_idMask)2532 m_namespaceURI(namespaceURI), 2533 m_localName(localName) 2543 2534 { 2544 2535 } … … 2549 2540 } 2550 2541 2551 NodeImpl *TagNodeListImpl::item ( unsigned long index ) const 2552 { 2553 return recursiveItem( index ); 2554 } 2555 2556 bool TagNodeListImpl::nodeMatches( NodeImpl *testNode ) const 2557 { 2558 return ( testNode->isElementNode() && 2559 (testNode->id() & m_idMask) == m_id); 2542 NodeImpl *TagNodeListImpl::item(unsigned long index) const 2543 { 2544 return recursiveItem(index); 2545 } 2546 2547 bool TagNodeListImpl::nodeMatches(NodeImpl *testNode) const 2548 { 2549 if (!testNode->isElementNode()) 2550 return false; 2551 2552 if (m_namespaceURI != starAtom && m_namespaceURI != testNode->namespaceURI()) 2553 return false; 2554 2555 return m_localName == starAtom || m_localName == testNode->localName(); 2560 2556 } 2561 2557 … … 2596 2592 } 2597 2593 2598 // ---------------------------------------------------------------------------- 2599 2600 // ### unused 2601 #if 0 2602 GenericRONamedNodeMapImpl::GenericRONamedNodeMapImpl(DocumentPtr* doc) 2603 : NamedNodeMapImpl() 2604 { 2605 m_doc = doc->document(); 2606 m_contents = new QPtrList<NodeImpl>; 2607 } 2608 2609 GenericRONamedNodeMapImpl::~GenericRONamedNodeMapImpl() 2610 { 2611 while (m_contents->count() > 0) 2612 m_contents->take(0)->deref(); 2613 2614 delete m_contents; 2615 } 2616 2617 NodeImpl *GenericRONamedNodeMapImpl::getNamedItem ( const DOMString &name, int &/*exceptioncode*/ ) const 2618 { 2619 QPtrListIterator<NodeImpl> it(*m_contents); 2620 for (; it.current(); ++it) 2621 if (it.current()->nodeName() == name) 2622 return it.current(); 2623 return 0; 2624 } 2625 2626 Node GenericRONamedNodeMapImpl::setNamedItem ( const Node &/*arg*/, int &exceptioncode ) 2627 { 2628 // can't modify this list through standard DOM functions 2629 // NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly 2630 exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR; 2631 return 0; 2632 } 2633 2634 Node GenericRONamedNodeMapImpl::removeNamedItem ( const DOMString &/*name*/, int &exceptioncode ) 2635 { 2636 // can't modify this list through standard DOM functions 2637 // NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly 2638 exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR; 2639 return 0; 2640 } 2641 2642 NodeImpl *GenericRONamedNodeMapImpl::item ( unsigned long index ) const 2643 { 2644 // ### check this when calling from javascript using -1 = 2^sizeof(int)-1 2645 // (also for other similar methods) 2646 if (index >= m_contents->count()) 2647 return 0; 2648 2649 return m_contents->at(index); 2650 } 2651 2652 unsigned long GenericRONamedNodeMapImpl::length( ) const 2653 { 2654 return m_contents->count(); 2655 } 2656 2657 NodeImpl *GenericRONamedNodeMapImpl::getNamedItemNS( const DOMString &namespaceURI, 2658 const DOMString &localName, 2659 int &/*exceptioncode*/ ) const 2660 { 2661 NodeImpl::Id searchId = m_doc->tagId(namespaceURI.implementation(), 2662 localName.implementation(), true); 2663 2664 QPtrListIterator<NodeImpl> it(*m_contents); 2665 for (; it.current(); ++it) 2666 if (it.current()->id() == searchId) 2667 return it.current(); 2668 2669 return 0; 2670 } 2671 2672 NodeImpl *GenericRONamedNodeMapImpl::setNamedItemNS( NodeImpl */*arg*/, int &exceptioncode ) 2673 { 2674 // can't modify this list through standard DOM functions 2675 // NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly 2676 exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR; 2677 return 0; 2678 } 2679 2680 NodeImpl *GenericRONamedNodeMapImpl::removeNamedItemNS( const DOMString &/*namespaceURI*/, 2681 const DOMString &/*localName*/, 2682 int &exceptioncode ) 2683 { 2684 // can't modify this list through standard DOM functions 2685 exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR; 2686 return 0; 2687 } 2688 2689 void GenericRONamedNodeMapImpl::addNode(NodeImpl *n) 2690 { 2691 // The spec says that in the case of duplicates we only keep the first one 2692 int exceptioncode = 0; 2693 if (getNamedItem(n->nodeName(),exceptioncode)) 2694 return; 2695 2696 n->ref(); 2697 m_contents->append(n); 2698 } 2699 2700 #endif 2594 } -
trunk/WebCore/khtml/xml/dom_nodeimpl.h
r9476 r9639 60 60 class NodeListImpl; 61 61 class NamedAttrMapImpl; 62 class QualifiedName; 62 63 class RegisteredEventListener; 63 64 // The namespace used for XHTML elements65 #define XHTML_NAMESPACE "http://www.w3.org/1999/xhtml"66 64 67 65 const Q_UINT16 noNamespace = 0; … … 103 101 104 102 // DOM methods & attributes for Node 103 virtual bool hasTagName(const QualifiedName& tagName) const { return false; } 105 104 virtual DOMString nodeName() const = 0; 106 105 virtual DOMString nodeValue() const; … … 123 122 virtual bool hasChildNodes ( ) const; 124 123 virtual NodeImpl *cloneNode ( bool deep ) = 0; 125 virtual DOMStringlocalName() const;126 virtual DOMStringnamespaceURI() const;127 virtual DOMStringprefix() const;128 virtual void setPrefix(const DOMString &_prefix, int &exceptioncode);124 virtual const AtomicString& localName() const; 125 virtual const AtomicString& namespaceURI() const; 126 virtual const AtomicString& prefix() const; 127 virtual void setPrefix(const AtomicString &_prefix, int &exceptioncode); 129 128 void normalize (); 130 129 static bool isSupported(const DOMString &feature, const DOMString &version); 131 130 132 NodeImpl *lastDescend ent() const;131 NodeImpl *lastDescendant() const; 133 132 134 133 // Other methods (not part of DOM) … … 138 137 virtual bool isAttributeNode() const { return false; } 139 138 virtual bool isTextNode() const { return false; } 139 virtual bool isCommentNode() const { return false; } 140 140 virtual bool isDocumentNode() const { return false; } 141 virtual bool isXMLElementNode() const { return false; }142 141 bool isBlockFlow() const; 143 142 bool isBlockFlowOrTable() const; … … 189 188 bool inSameContainingBlockFlowElement(NodeImpl *); 190 189 191 // used by the parser. Doesn't do as many error checkings as192 // appendChild(), and returns the n ode into which will be parsed next.190 // used by the parser. Checks against the DTD, unlike DOM operations like 191 // appendChild(), and returns the new container node for future insertions as you parse. 193 192 virtual NodeImpl *addChild(NodeImpl *newChild); 194 193 … … 197 196 // This is only needed for <applet> and <object> elements, which can't lay themselves out 198 197 // until they know all of their nested <param>s. [3603191, 4040848] 199 virtual void closeRenderer() { } 200 201 typedef Q_UINT32 Id; 202 // id() is used to easily and exactly identify a node. It 203 // is optimized for quick comparison and low memory consumption. 204 // its value depends on the owner document of the node and is 205 // categorized in the following way: 206 // 1..ID_LAST_TAG: the node inherits HTMLElementImpl and is 207 // part of the HTML namespace. 208 // The HTML namespace is either the global 209 // one (no namespace) or the XHTML namespace 210 // depending on the owner document's doctype 211 // ID_LAST_TAG+1..0xffff: non-HTML elements in the global namespace 212 // others non-HTML elements in a namespace. 213 // the upper 16 bit identify the namespace 214 // the lower 16 bit identify the local part of the 215 // qualified element name. 216 virtual Id id() const { return 0; }; 217 #if APPLE_CHANGES 218 Id identifier() const; 219 #endif 198 virtual void closeRenderer() {} 199 200 typedef Q_UINT32 Id; // FIXME: Yank this once attributes are also switched over. 201 220 202 enum MouseEventType { 221 203 MousePress, … … 279 261 virtual bool isMouseFocusable() const; 280 262 281 virtual bool isInline() const;282 283 263 virtual bool isContentEditable() const; 284 264 virtual QRect getRect() const; … … 370 350 void setRenderer(khtml::RenderObject* renderer) { m_render = renderer; } 371 351 372 void checkSetPrefix(const DOMString &_prefix, int &exceptioncode); 373 void checkAddChild(NodeImpl *newChild, int &exceptioncode); 352 void checkSetPrefix(const AtomicString &_prefix, int &exceptioncode); 374 353 bool isAncestor(const NodeImpl *) const; 375 virtual bool childAllowed( NodeImpl *newChild ); 376 354 355 // These two methods are mutually exclusive. The former is used to do strict error-checking 356 // when adding children via the public DOM API (e.g., appendChild()). The latter is called only when parsing, 357 // to sanity-check against the DTD for error recovery. 358 void checkAddChild(NodeImpl *newChild, int &exceptioncode); // Error-checking when adding via the DOM API 359 virtual bool childAllowed(NodeImpl *newChild); // Error-checking during parsing that checks the DTD 360 377 361 virtual long maxOffset() const; 378 362 long maxDeepOffset() const; … … 482 466 void notifyLocalNodeListsSubtreeModified(); 483 467 484 SharedPtr<NodeListImpl> getElementsByTagName(const DOMString &name) { return getElementsByTagNameNS( DOMString(), name); }468 SharedPtr<NodeListImpl> getElementsByTagName(const DOMString &name) { return getElementsByTagNameNS("*", name); } 485 469 SharedPtr<NodeListImpl> getElementsByTagNameNS(const DOMString &namespaceURI, const DOMString &localName); 486 470 … … 618 602 virtual bool nodeMatches( NodeImpl *testNode ) const; 619 603 }; 620 621 622 /**623 * NodeList which lists all Nodes in a document with a given tag name624 */625 class TagNodeListImpl : public NodeListImpl626 {627 public:628 TagNodeListImpl( NodeImpl *n, NodeImpl::Id tagId, NodeImpl::Id tagIdMask );629 630 // DOM methods overridden from parent classes631 632 virtual unsigned long length() const;633 virtual NodeImpl *item ( unsigned long index ) const;634 635 // Other methods (not part of DOM)636 637 protected:638 virtual bool nodeMatches( NodeImpl *testNode ) const;639 640 NodeImpl::Id m_id;641 NodeImpl::Id m_idMask;642 };643 644 604 645 605 /** -
trunk/WebCore/khtml/xml/dom_position.cpp
r9447 r9639 36 36 #include "dom2_viewsimpl.h" 37 37 #include "helper.h" 38 #include "htmltags.h"39 38 #include "text_affinity.h" 40 39 #include "visible_position.h" … … 46 45 #include "rendering/render_text.h" 47 46 #include "editing/visible_text.h" 47 #include "htmlnames.h" 48 48 49 49 #if APPLE_CHANGES … … 441 441 // stop before going above the body, up into the head 442 442 // return the last visible streamer position 443 if (currentNode-> id() == ID_BODY&& currentOffset >= (int) currentNode->childNodeCount())443 if (currentNode->hasTagName(HTMLNames::body()) && currentOffset >= (int) currentNode->childNodeCount()) 444 444 break; 445 445 … … 695 695 696 696 if (node() == pos.node()) { 697 if (node()-> id() == ID_BR)697 if (node()->hasTagName(HTMLNames::br())) 698 698 return false; 699 699 … … 707 707 } 708 708 709 if (node()-> id() == ID_BR&& pos.inRenderedContent())709 if (node()->hasTagName(HTMLNames::br()) && pos.inRenderedContent()) 710 710 return true; 711 711 712 if (pos.node()-> id() == ID_BR&& inRenderedContent())712 if (pos.node()->hasTagName(HTMLNames::br()) && inRenderedContent()) 713 713 return true; 714 714 … … 765 765 return Position(); 766 766 767 if (upstream().node()-> id() == ID_BR)767 if (upstream().node()->hasTagName(HTMLNames::br())) 768 768 return Position(); 769 769 … … 795 795 } 796 796 797 if (downstream().node()-> id() == ID_BR)797 if (downstream().node()->hasTagName(HTMLNames::br())) 798 798 return Position(); 799 799 -
trunk/WebCore/khtml/xml/dom_qname.cpp
r9403 r9639 20 20 */ 21 21 22 #include <qptrdict.h>23 22 #include "dom_qname.h" 23 #include "misc/hashset.h" 24 25 using khtml::HashSet; 24 26 25 27 namespace DOM { 26 28 27 static QPtrDict<QPtrDict<QPtrDict<QualifiedName::QualifiedNameImpl> > >* gNameCache = 0; 29 struct QualifiedNameComponents { 30 DOMStringImpl *m_prefix; 31 DOMStringImpl *m_localName; 32 DOMStringImpl *m_namespace; 33 }; 34 35 // Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's 36 static const unsigned PHI = 0x9e3779b9U; 37 38 inline unsigned hashComponents(const QualifiedNameComponents& buf) 39 { 40 unsigned l = sizeof(QualifiedNameComponents) / sizeof(uint16_t); 41 const uint16_t *s = reinterpret_cast<const uint16_t*>(&buf); 42 uint32_t hash = PHI; 43 uint32_t tmp; 44 45 int rem = l & 1; 46 l >>= 1; 47 48 // Main loop 49 for (; l > 0; l--) { 50 hash += s[0]; 51 tmp = (s[1] << 11) ^ hash; 52 hash = (hash << 16) ^ tmp; 53 s += 2; 54 hash += hash >> 11; 55 } 56 57 // Handle end case 58 if (rem) { 59 hash += s[0]; 60 hash ^= hash << 11; 61 hash += hash >> 17; 62 } 63 64 // Force "avalanching" of final 127 bits 65 hash ^= hash << 3; 66 hash += hash >> 5; 67 hash ^= hash << 2; 68 hash += hash >> 15; 69 hash ^= hash << 10; 70 71 // this avoids ever returning a hash code of 0, since that is used to 72 // signal "hash not computed yet", using a value that is likely to be 73 // effectively the same as 0 when the low bits are masked 74 if (hash == 0) 75 hash = 0x80000000; 76 77 return hash; 78 } 79 80 struct QNameHash { 81 static unsigned hash(const QualifiedName::QualifiedNameImpl *name) { 82 QualifiedNameComponents components = { name->m_prefix.implementation(), 83 name->m_localName.implementation(), 84 name->m_namespace.implementation() }; 85 return hashComponents(components); 86 } 87 static bool equal(const QualifiedName::QualifiedNameImpl *a, const QualifiedName::QualifiedNameImpl *b) { return a == b; } 88 }; 89 90 typedef HashSet<QualifiedName::QualifiedNameImpl*, QNameHash> QNameSet; 91 92 static QNameSet *gNameCache; 93 94 inline bool equalComponents(QualifiedName::QualifiedNameImpl* const& name, const QualifiedNameComponents &components) 95 { 96 return components.m_localName == name->m_localName.implementation() && 97 components.m_namespace == name->m_namespace.implementation() && 98 components.m_prefix == name->m_prefix.implementation(); 99 } 100 101 inline QualifiedName::QualifiedNameImpl *convertComponents(const QualifiedNameComponents& components, unsigned hash) 102 { 103 return new QualifiedName::QualifiedNameImpl(components.m_prefix, components.m_localName, components.m_namespace); 104 } 105 28 106 29 107 QualifiedName::QualifiedName(const AtomicString& p, const AtomicString& l, const AtomicString& n) 108 : m_impl(0) 30 109 { 31 // Obtain an appropriate inner from our dictionary. 32 QPtrDict<QPtrDict<QualifiedNameImpl> >* namespaceDict = 0; 33 QPtrDict<QualifiedNameImpl>* prefixDict = 0; 34 if (gNameCache) { 35 namespaceDict = gNameCache->find((void*)(n.implementation())); 36 if (namespaceDict) { 37 prefixDict = namespaceDict->find((void*)p.implementation()); 38 if (prefixDict) 39 m_impl = prefixDict->find((void*)l.implementation()); 40 } 41 } 42 43 if (!m_impl) { 44 m_impl = new QualifiedNameImpl(p, l, n); 45 46 // Put the object into the hash. 47 if (!gNameCache) 48 gNameCache = new QPtrDict<QPtrDict<QPtrDict<QualifiedNameImpl> > >; 49 50 if (!namespaceDict) { 51 namespaceDict = new QPtrDict<QPtrDict<QualifiedNameImpl> >; 52 namespaceDict->setAutoDelete(true); 53 gNameCache->insert((void*)n.implementation(), namespaceDict); 54 } 55 56 if (!prefixDict) { 57 prefixDict = new QPtrDict<QualifiedNameImpl>; 58 namespaceDict->insert((void*)p.implementation(), prefixDict); 59 } 60 61 prefixDict->insert((void*)l.implementation(), m_impl); 62 } 63 110 if (!gNameCache) 111 gNameCache = new QNameSet; 112 QualifiedNameComponents components = { p.implementation(), l.implementation(), n.implementation() }; 113 m_impl = *gNameCache->insert<QualifiedNameComponents, hashComponents, equalComponents, convertComponents>(components).first; 64 114 ref(); 65 115 } … … 89 139 void QualifiedName::deref() 90 140 { 91 if (m_impl->refCount() == 1) { 92 // Before decrementing the ref to 0, remove ourselves from the hash table. 93 QPtrDict<QPtrDict<QualifiedNameImpl> >* namespaceDict = 0; 94 QPtrDict<QualifiedNameImpl>* prefixDict = 0; 95 if (gNameCache) { 96 namespaceDict = gNameCache->find((void*)(namespaceURI().implementation())); 97 if (namespaceDict) { 98 prefixDict = namespaceDict->find((void*)prefix().implementation()); 99 if (prefixDict) 100 prefixDict->remove((void*)localName().implementation()); 101 } 102 } 103 } 104 141 if (m_impl->hasOneRef()) 142 gNameCache->remove(m_impl); 143 105 144 m_impl->deref(); 106 145 } 107 146 108 bool operator==(const AtomicString& a, const QualifiedName& q) 109 { 110 return a == q.localName(); 111 } 112 113 bool operator==(const QualifiedName& q, const AtomicString& a) 147 void QualifiedName::setPrefix(const AtomicString& prefix) 114 148 { 115 return a == q.localName(); 149 QualifiedName other(prefix, localName(), namespaceURI()); 150 *this = other; 116 151 } 117 152 -
trunk/WebCore/khtml/xml/dom_qname.h
r9403 r9639 33 33 QualifiedNameImpl(const AtomicString& p, const AtomicString& l, const AtomicString& n) :m_prefix(p), m_localName(l), m_namespace(n) {} 34 34 35 friend class QualifiedName;36 37 private:38 35 AtomicString m_prefix; 39 36 AtomicString m_localName; … … 48 45 const QualifiedName& operator=(const QualifiedName& other); 49 46 50 DOMStringImpl* localNamePtr() const { return localName().implementation(); }51 52 47 bool operator==(const QualifiedName& other) const { return m_impl == other.m_impl; } 53 48 bool operator!=(const QualifiedName& other) const { return !(*this == other); } 54 49 55 50 bool matches(const QualifiedName& other) const { return m_impl == other.m_impl || (localName() == other.localName() && namespaceURI() == other.namespaceURI()); } 51 52 bool hasPrefix() const { return m_impl->m_prefix != nullAtom; } 53 void setPrefix(const AtomicString& prefix); 56 54 57 55 const AtomicString& prefix() const { return m_impl->m_prefix; } … … 67 65 }; 68 66 69 bool operator==(const AtomicString& a, const QualifiedName& q); 67 inline bool operator==(const AtomicString& a, const QualifiedName& q) { return a == q.localName(); } 70 68 inline bool operator!=(const AtomicString& a, const QualifiedName& q) { return a != q.localName(); } 71 bool operator==(const QualifiedName& q, const AtomicString& a); 69 inline bool operator==(const QualifiedName& q, const AtomicString& a) { return a == q.localName(); } 72 70 inline bool operator!=(const QualifiedName& q, const AtomicString& a) { return a != q.localName(); } 73 74 71 75 72 } -
trunk/WebCore/khtml/xml/dom_textimpl.cpp
r7861 r9639 305 305 } 306 306 307 const AtomicString& CommentImpl::localName() const 308 { 309 return commentAtom; 310 } 311 307 312 DOMString CommentImpl::nodeName() const 308 313 { 309 return "#comment";314 return commentAtom.string(); 310 315 } 311 316 … … 318 323 { 319 324 return getDocument()->createComment( str ); 320 }321 322 NodeImpl::Id CommentImpl::id() const323 {324 return ID_COMMENT;325 325 } 326 326 … … 395 395 } 396 396 397 const AtomicString& TextImpl::localName() const 398 { 399 return textAtom; 400 } 401 397 402 DOMString TextImpl::nodeName() const 398 403 { 399 return "#text";404 return textAtom.string(); 400 405 } 401 406 … … 463 468 } 464 469 465 NodeImpl::Id TextImpl::id() const466 {467 return ID_TEXT;468 }469 470 470 void TextImpl::recalcStyle( StyleChange change ) 471 471 { -
trunk/WebCore/khtml/xml/dom_textimpl.h
r9153 r9639 96 96 97 97 // DOM methods overridden from parent classes 98 const AtomicString& localName() const; 98 99 virtual DOMString nodeName() const; 99 100 virtual unsigned short nodeType() const; … … 101 102 102 103 // Other methods (not part of DOM) 103 104 virtual Id id() const; 104 virtual bool isCommentNode() const { return true; } 105 105 virtual bool childTypeAllowed( unsigned short type ); 106 106 … … 122 122 123 123 // DOM methods overridden from parent classes 124 const AtomicString& localName() const; 124 125 virtual DOMString nodeName() const; 125 126 virtual unsigned short nodeType() const; … … 129 130 130 131 virtual bool isTextNode() const { return true; } 131 virtual Id id() const;132 132 virtual void attach(); 133 133 virtual bool rendererIsNeeded(khtml::RenderStyle *); -
trunk/WebCore/khtml/xml/xml_tokenizer.cpp
r9105 r9639 27 27 #include "html/html_headimpl.h" 28 28 #include "html/html_tableimpl.h" 29 #include " misc/htmltags.h"29 #include "htmlnames.h" 30 30 #include "misc/htmlattrs.h" 31 31 #include "misc/loader.h" … … 45 45 using DOM::DOMString; 46 46 using DOM::ElementImpl; 47 using DOM::HTMLNames; 47 48 using DOM::HTMLScriptElementImpl; 48 49 using DOM::HTMLTableSectionElementImpl; … … 323 324 // We want to consolidate this with the HTML parser and HTML DOM code at some point. 324 325 // For now, it's too risky to rip that code up. 325 if (m_currentNode-> id() == ID_TABLE&&326 newElement-> id() == ID_TR&&326 if (m_currentNode->hasTagName(HTMLNames::table()) && 327 newElement->hasTagName(HTMLNames::tr()) && 327 328 m_currentNode->isHTMLElement() && newElement->isHTMLElement()) { 328 329 NodeImpl* implicitTBody = 329 new HTMLTableSectionElementImpl( m_doc, ID_TBODY, true /* implicit */);330 new HTMLTableSectionElementImpl(HTMLNames::tbody(), m_doc, true /* implicit */); 330 331 m_currentNode->addChild(implicitTBody); 331 332 if (m_view && !implicitTBody->attached()) … … 334 335 } 335 336 336 if (newElement-> id() == ID_SCRIPT)337 if (newElement->hasTagName(HTMLNames::script())) 337 338 static_cast<HTMLScriptElementImpl *>(newElement)->setCreatedByParser(true); 338 339 … … 612 613 NodeImpl* root = doc->documentElement(); 613 614 if (!root) { 614 root = doc->createElementNS( XHTML_NAMESPACE, "html", exceptioncode);615 NodeImpl* body = doc->createElementNS( XHTML_NAMESPACE, "body", exceptioncode);615 root = doc->createElementNS(HTMLNames::xhtmlNamespaceURI(), "html", exceptioncode); 616 NodeImpl* body = doc->createElementNS(HTMLNames::xhtmlNamespaceURI(), "body", exceptioncode); 616 617 root->appendChild(body, exceptioncode); 617 618 doc->appendChild(root, exceptioncode); … … 619 620 } 620 621 621 ElementImpl* reportElement = doc->createElementNS( XHTML_NAMESPACE, "parsererror", exceptioncode);622 ElementImpl* reportElement = doc->createElementNS(HTMLNames::xhtmlNamespaceURI(), "parsererror", exceptioncode); 622 623 reportElement->setAttribute(ATTR_STYLE, "white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"); 623 ElementImpl* h3 = doc->createElementNS( XHTML_NAMESPACE, "h3", exceptioncode);624 ElementImpl* h3 = doc->createElementNS(HTMLNames::xhtmlNamespaceURI(), "h3", exceptioncode); 624 625 h3->appendChild(doc->createTextNode("This page contains the following errors:"), exceptioncode); 625 626 reportElement->appendChild(h3, exceptioncode); 626 ElementImpl* fixed = doc->createElementNS( XHTML_NAMESPACE, "div", exceptioncode);627 ElementImpl* fixed = doc->createElementNS(HTMLNames::xhtmlNamespaceURI(), "div", exceptioncode); 627 628 fixed->setAttribute(ATTR_STYLE, "font-family:monospace;font-size:12px"); 628 629 NodeImpl* textNode = doc->createTextNode(m_errorMessages); 629 630 fixed->appendChild(textNode, exceptioncode); 630 631 reportElement->appendChild(fixed, exceptioncode); 631 h3 = doc->createElementNS( XHTML_NAMESPACE, "h3", exceptioncode);632 h3 = doc->createElementNS(HTMLNames::xhtmlNamespaceURI(), "h3", exceptioncode); 632 633 reportElement->appendChild(h3, exceptioncode); 633 634 … … 635 636 #ifdef KHTML_XSLT 636 637 if (doc->transformSourceDocument()) { 637 ElementImpl* par = doc->createElementNS( XHTML_NAMESPACE, "p", exceptioncode);638 ElementImpl* par = doc->createElementNS(HTMLNames::xhtmlNamespaceURI(), "p", exceptioncode); 638 639 reportElement->appendChild(par, exceptioncode); 639 640 par->setAttribute(ATTR_STYLE, "white-space: normal"); … … 651 652 // that is found, add it to the m_scripts list from which they will be executed 652 653 653 if (n-> id() == ID_SCRIPT) {654 if (n->hasTagName(HTMLNames::script())) { 654 655 m_scripts.append(static_cast<HTMLScriptElementImpl*>(n)); 655 656 } -
trunk/WebCore/kwq/DOM.mm
r9181 r9639 45 45 #import "dom_xmlimpl.h" 46 46 #import "html_elementimpl.h" 47 #import "htmltags.h"48 47 49 48 #import "khtml_part.h" … … 73 72 using DOM::FilterNode; 74 73 using DOM::HTMLElementImpl; 74 using DOM::HTMLNames; 75 75 using DOM::NamedNodeMapImpl; 76 76 using DOM::Node; … … 339 339 340 340 int exceptionCode = 0; 341 [self _nodeImpl]->setPrefix(prefix, exceptionCode); 341 DOMString prefixStr(prefix); 342 [self _nodeImpl]->setPrefix(prefixStr.implementation(), exceptionCode); 342 343 raiseOnDOMError(exceptionCode); 343 344 } … … 400 401 case Node::ELEMENT_NODE: 401 402 if (impl->isHTMLElement()) { 402 // FIXME: There are no identifiers for HTMLHeadingElement, HTMLModElement, 403 // HTMLTableCaptionElement, HTMLTableColElement, HTMLTableSectionElement. 404 // Find other ways to identify them. 405 switch (impl->identifier()) { 406 case ID_HTML: 407 wrapperClass = [DOMHTMLHtmlElement class]; 408 break; 409 case ID_HEAD: 410 wrapperClass = [DOMHTMLHeadElement class]; 411 break; 412 case ID_LINK: 413 wrapperClass = [DOMHTMLLinkElement class]; 414 break; 415 case ID_TITLE: 416 wrapperClass = [DOMHTMLTitleElement class]; 417 break; 418 case ID_META: 419 wrapperClass = [DOMHTMLMetaElement class]; 420 break; 421 case ID_BASE: 422 wrapperClass = [DOMHTMLBaseElement class]; 423 break; 424 case ID_ISINDEX: 425 wrapperClass = [DOMHTMLIsIndexElement class]; 426 break; 427 case ID_STYLE: 428 wrapperClass = [DOMHTMLStyleElement class]; 429 break; 430 case ID_BODY: 431 wrapperClass = [DOMHTMLBodyElement class]; 432 break; 433 case ID_FORM: 434 wrapperClass = [DOMHTMLFormElement class]; 435 break; 436 case ID_SELECT: 437 wrapperClass = [DOMHTMLSelectElement class]; 438 break; 439 case ID_OPTGROUP: 440 wrapperClass = [DOMHTMLOptGroupElement class]; 441 break; 442 case ID_OPTION: 443 wrapperClass = [DOMHTMLOptionElement class]; 444 break; 445 case ID_INPUT: 446 wrapperClass = [DOMHTMLInputElement class]; 447 break; 448 case ID_TEXTAREA: 449 wrapperClass = [DOMHTMLTextAreaElement class]; 450 break; 451 case ID_BUTTON: 452 wrapperClass = [DOMHTMLButtonElement class]; 453 break; 454 case ID_LABEL: 455 wrapperClass = [DOMHTMLLabelElement class]; 456 break; 457 case ID_FIELDSET: 458 wrapperClass = [DOMHTMLFieldSetElement class]; 459 break; 460 case ID_LEGEND: 461 wrapperClass = [DOMHTMLLegendElement class]; 462 break; 463 case ID_UL: 464 wrapperClass = [DOMHTMLUListElement class]; 465 break; 466 case ID_OL: 467 wrapperClass = [DOMHTMLOListElement class]; 468 break; 469 case ID_DL: 470 wrapperClass = [DOMHTMLDListElement class]; 471 break; 472 case ID_DIR: 473 wrapperClass = [DOMHTMLDirectoryElement class]; 474 break; 475 case ID_MENU: 476 wrapperClass = [DOMHTMLMenuElement class]; 477 break; 478 case ID_LI: 479 wrapperClass = [DOMHTMLLIElement class]; 480 break; 481 case ID_DIV: 482 wrapperClass = [DOMHTMLDivElement class]; 483 break; 484 case ID_P: 485 wrapperClass = [DOMHTMLParagraphElement class]; 486 break; 487 case ID_Q: 488 wrapperClass = [DOMHTMLQuoteElement class]; 489 break; 490 case ID_PRE: 491 wrapperClass = [DOMHTMLPreElement class]; 492 break; 493 case ID_BR: 494 wrapperClass = [DOMHTMLBRElement class]; 495 break; 496 case ID_BASEFONT: 497 wrapperClass = [DOMHTMLFontElement class]; 498 break; 499 case ID_FONT: 500 wrapperClass = [DOMHTMLFontElement class]; 501 break; 502 case ID_HR: 503 wrapperClass = [DOMHTMLHRElement class]; 504 break; 505 case ID_A: 506 wrapperClass = [DOMHTMLAnchorElement class]; 507 break; 508 case ID_IMG: 509 wrapperClass = [DOMHTMLImageElement class]; 510 break; 511 case ID_OBJECT: 512 wrapperClass = [DOMHTMLObjectElement class]; 513 break; 514 case ID_PARAM: 515 wrapperClass = [DOMHTMLParamElement class]; 516 break; 517 case ID_APPLET: 518 wrapperClass = [DOMHTMLAppletElement class]; 519 break; 520 case ID_MAP: 521 wrapperClass = [DOMHTMLMapElement class]; 522 break; 523 case ID_AREA: 524 wrapperClass = [DOMHTMLAreaElement class]; 525 break; 526 case ID_SCRIPT: 527 wrapperClass = [DOMHTMLScriptElement class]; 528 break; 529 case ID_TABLE: 530 wrapperClass = [DOMHTMLTableElement class]; 531 break; 532 case ID_TD: 533 wrapperClass = [DOMHTMLTableCellElement class]; 534 break; 535 case ID_TR: 536 wrapperClass = [DOMHTMLTableRowElement class]; 537 break; 538 case ID_FRAMESET: 539 wrapperClass = [DOMHTMLFrameSetElement class]; 540 break; 541 case ID_FRAME: 542 wrapperClass = [DOMHTMLFrameElement class]; 543 break; 544 case ID_IFRAME: 545 wrapperClass = [DOMHTMLIFrameElement class]; 546 break; 547 default: 548 wrapperClass = [DOMHTMLElement class]; 549 } 403 // FIXME: Reflect marquee once the API has been determined. 404 // FIXME: We could make the HTML classes hand back their class names and then use that to make 405 // the appropriate Obj-C class from the string. 406 HTMLElementImpl* htmlElt = static_cast<HTMLElementImpl*>(impl); 407 if (htmlElt->hasLocalName(HTMLNames::html())) 408 wrapperClass = [DOMHTMLHtmlElement class]; 409 else if (htmlElt->hasLocalName(HTMLNames::head())) 410 wrapperClass = [DOMHTMLHeadElement class]; 411 else if (htmlElt->hasLocalName(HTMLNames::link())) 412 wrapperClass = [DOMHTMLLinkElement class]; 413 else if (htmlElt->hasLocalName(HTMLNames::title())) 414 wrapperClass = [DOMHTMLTitleElement class]; 415 else if (htmlElt->hasLocalName(HTMLNames::meta())) 416 wrapperClass = [DOMHTMLMetaElement class]; 417 else if (htmlElt->hasLocalName(HTMLNames::base())) 418 wrapperClass = [DOMHTMLBaseElement class]; 419 else if (htmlElt->hasLocalName(HTMLNames::isindex())) 420 wrapperClass = [DOMHTMLIsIndexElement class]; 421 else if (htmlElt->hasLocalName(HTMLNames::style())) 422 wrapperClass = [DOMHTMLStyleElement class]; 423 else if (htmlElt->hasLocalName(HTMLNames::body())) 424 wrapperClass = [DOMHTMLBodyElement class]; 425 else if (htmlElt->hasLocalName(HTMLNames::form())) 426 wrapperClass = [DOMHTMLFormElement class]; 427 else if (htmlElt->hasLocalName(HTMLNames::select())) 428 wrapperClass = [DOMHTMLSelectElement class]; 429 else if (htmlElt->hasLocalName(HTMLNames::optgroup())) 430 wrapperClass = [DOMHTMLOptGroupElement class]; 431 else if (htmlElt->hasLocalName(HTMLNames::option())) 432 wrapperClass = [DOMHTMLOptionElement class]; 433 else if (htmlElt->hasLocalName(HTMLNames::input())) 434 wrapperClass = [DOMHTMLInputElement class]; 435 else if (htmlElt->hasLocalName(HTMLNames::textarea())) 436 wrapperClass = [DOMHTMLTextAreaElement class]; 437 else if (htmlElt->hasLocalName(HTMLNames::button())) 438 wrapperClass = [DOMHTMLButtonElement class]; 439 else if (htmlElt->hasLocalName(HTMLNames::label())) 440 wrapperClass = [DOMHTMLLabelElement class]; 441 else if (htmlElt->hasLocalName(HTMLNames::fieldset())) 442 wrapperClass = [DOMHTMLFieldSetElement class]; 443 else if (htmlElt->hasLocalName(HTMLNames::legend())) 444 wrapperClass = [DOMHTMLLegendElement class]; 445 else if (htmlElt->hasLocalName(HTMLNames::ul())) 446 wrapperClass = [DOMHTMLUListElement class]; 447 else if (htmlElt->hasLocalName(HTMLNames::ol())) 448 wrapperClass = [DOMHTMLOListElement class]; 449 else if (htmlElt->hasLocalName(HTMLNames::dl())) 450 wrapperClass = [DOMHTMLDListElement class]; 451 else if (htmlElt->hasLocalName(HTMLNames::dir())) 452 wrapperClass = [DOMHTMLDirectoryElement class]; 453 else if (htmlElt->hasLocalName(HTMLNames::menu())) 454 wrapperClass = [DOMHTMLMenuElement class]; 455 else if (htmlElt->hasLocalName(HTMLNames::li())) 456 wrapperClass = [DOMHTMLLIElement class]; 457 else if (htmlElt->hasLocalName(HTMLNames::div())) 458 wrapperClass = [DOMHTMLDivElement class]; 459 else if (htmlElt->hasLocalName(HTMLNames::p())) 460 wrapperClass = [DOMHTMLParagraphElement class]; 461 else if (htmlElt->hasLocalName(HTMLNames::h1()) || 462 htmlElt->hasLocalName(HTMLNames::h2()) || 463 htmlElt->hasLocalName(HTMLNames::h3()) || 464 htmlElt->hasLocalName(HTMLNames::h4()) || 465 htmlElt->hasLocalName(HTMLNames::h5()) || 466 htmlElt->hasLocalName(HTMLNames::h6())) 467 wrapperClass = [DOMHTMLHeadingElement class]; 468 else if (htmlElt->hasLocalName(HTMLNames::q())) 469 wrapperClass = [DOMHTMLQuoteElement class]; 470 else if (htmlElt->hasLocalName(HTMLNames::pre())) 471 wrapperClass = [DOMHTMLPreElement class]; 472 else if (htmlElt->hasLocalName(HTMLNames::br())) 473 wrapperClass = [DOMHTMLBRElement class]; 474 else if (htmlElt->hasLocalName(HTMLNames::basefont())) 475 wrapperClass = [DOMHTMLBaseFontElement class]; 476 else if (htmlElt->hasLocalName(HTMLNames::font())) 477 wrapperClass = [DOMHTMLFontElement class]; 478 else if (htmlElt->hasLocalName(HTMLNames::hr())) 479 wrapperClass = [DOMHTMLHRElement class]; 480 else if (htmlElt->hasLocalName(HTMLNames::a())) 481 wrapperClass = [DOMHTMLAnchorElement class]; 482 else if (htmlElt->hasLocalName(HTMLNames::img()) || 483 htmlElt->hasLocalName(HTMLNames::canvas())) 484 wrapperClass = [DOMHTMLImageElement class]; 485 else if (htmlElt->hasLocalName(HTMLNames::object())) 486 wrapperClass = [DOMHTMLObjectElement class]; 487 else if (htmlElt->hasLocalName(HTMLNames::param())) 488 wrapperClass = [DOMHTMLParamElement class]; 489 else if (htmlElt->hasLocalName(HTMLNames::applet())) 490 wrapperClass = [DOMHTMLAppletElement class]; 491 else if (htmlElt->hasLocalName(HTMLNames::map())) 492 wrapperClass = [DOMHTMLMapElement class]; 493 else if (htmlElt->hasLocalName(HTMLNames::area())) 494 wrapperClass = [DOMHTMLAreaElement class]; 495 else if (htmlElt->hasLocalName(HTMLNames::script())) 496 wrapperClass = [DOMHTMLScriptElement class]; 497 else if (htmlElt->hasLocalName(HTMLNames::table())) 498 wrapperClass = [DOMHTMLTableElement class]; 499 else if (htmlElt->hasLocalName(HTMLNames::thead()) || 500 htmlElt->hasLocalName(HTMLNames::tbody()) || 501 htmlElt->hasLocalName(HTMLNames::tfoot())) 502 wrapperClass = [DOMHTMLTableSectionElement class]; 503 else if (htmlElt->hasLocalName(HTMLNames::td())) 504 wrapperClass = [DOMHTMLTableCellElement class]; 505 else if (htmlElt->hasLocalName(HTMLNames::tr())) 506 wrapperClass = [DOMHTMLTableRowElement class]; 507 else if (htmlElt->hasLocalName(HTMLNames::col()) || 508 htmlElt->hasLocalName(HTMLNames::colgroup())) 509 wrapperClass = [DOMHTMLTableColElement class]; 510 else if (htmlElt->hasLocalName(HTMLNames::caption())) 511 wrapperClass = [DOMHTMLTableCaptionElement class]; 512 else if (htmlElt->hasLocalName(HTMLNames::frameset())) 513 wrapperClass = [DOMHTMLFrameSetElement class]; 514 else if (htmlElt->hasLocalName(HTMLNames::frame())) 515 wrapperClass = [DOMHTMLFrameElement class]; 516 else if (htmlElt->hasLocalName(HTMLNames::iframe())) 517 wrapperClass = [DOMHTMLIFrameElement class]; 518 else 519 wrapperClass = [DOMHTMLElement class]; 550 520 } else { 551 521 wrapperClass = [DOMElement class]; … … 1269 1239 - (NSString *)tagName 1270 1240 { 1271 return [self _elementImpl]-> tagName();1241 return [self _elementImpl]->nodeName(); 1272 1242 } 1273 1243 -
trunk/WebCore/kwq/DOMHTML.mm
r9169 r9639 75 75 using DOM::HTMLFrameElementImpl; 76 76 using DOM::HTMLFrameSetElementImpl; 77 using DOM::HTMLGenericElementImpl;78 77 using DOM::HTMLGenericFormElementImpl; 79 78 using DOM::HTMLHeadElementImpl; … … 1906 1905 @implementation DOMHTMLQuoteElement 1907 1906 1908 - (HTML GenericElementImpl *)_quoteElementImpl1909 { 1910 return static_cast<HTML GenericElementImpl *>(DOM_cast<NodeImpl *>(_internal));1907 - (HTMLElementImpl *)_quoteElementImpl 1908 { 1909 return static_cast<HTMLElementImpl *>(DOM_cast<NodeImpl *>(_internal)); 1911 1910 } 1912 1911 -
trunk/WebCore/kwq/KWQAccObject.mm
r9611 r9639 49 49 #import "dom2_range.h" 50 50 #import "htmlattrs.h" 51 #import "htmltags.h"52 51 #import "khtmlview.h" 53 52 #import "khtml_part.h" … … 78 77 using DOM::HTMLInputElementImpl; 79 78 using DOM::HTMLMapElementImpl; 79 using DOM::HTMLNames; 80 80 using DOM::Node; 81 81 using DOM::NodeImpl; … … 367 367 if (m_renderer->isListMarker()) 368 368 return @"AXListMarker"; 369 if (m_renderer->element() && m_renderer->element()-> identifier() == ID_BUTTON)369 if (m_renderer->element() && m_renderer->element()->hasTagName(HTMLNames::button())) 370 370 return NSAccessibilityButtonRole; 371 371 if (m_renderer->isText()) … … 533 533 return nil; 534 534 535 if (m_renderer->element()->isHTMLElement() && m_renderer->element()-> identifier() == ID_BUTTON)535 if (m_renderer->element()->isHTMLElement() && m_renderer->element()->hasTagName(HTMLNames::button())) 536 536 return [self textUnderElement]; 537 537 if (m_renderer->element()->isLink()) … … 623 623 !m_renderer->isImage() && 624 624 !(m_renderer->element() && m_renderer->element()->isHTMLElement() && 625 m_renderer->element()-> identifier() == ID_BUTTON));625 m_renderer->element()->hasTagName(HTMLNames::button()))); 626 626 } 627 627 -
trunk/WebCore/kwq/KWQFont.h
r4024 r9639 38 38 public: 39 39 enum Weight { Normal = 50, Bold = 63 }; 40 enum Pitch { Unknown, Fixed, Variable }; 40 41 41 42 QFont(); … … 62 63 int pixelSize() const { return (int)_size; } 63 64 64 bool isFixedPitch() const; 65 bool isFixedPitch() const { if (_pitch == Unknown) determinePitch(); return _pitch == Fixed; }; 66 void determinePitch() const; 65 67 66 68 void setPrinterFont(bool); … … 80 82 int _trait; 81 83 float _size; 82 bool _isPrinterFont; 84 bool _isPrinterFont : 1; 85 mutable Pitch _pitch : 2; 83 86 mutable NSFont *_NSFont; 84 87 }; -
trunk/WebCore/kwq/KWQFont.mm
r8836 r9639 35 35 , _size(12.0) 36 36 , _isPrinterFont(false) 37 , _pitch(Unknown) 37 38 , _NSFont(0) 38 39 { … … 49 50 , _size(other._size) 50 51 , _isPrinterFont(other._isPrinterFont) 52 , _pitch(other._pitch) 51 53 , _NSFont(KWQRetain(other._NSFont)) 52 54 { … … 59 61 _size = other._size; 60 62 _isPrinterFont = other._isPrinterFont; 63 _pitch = other._pitch; 61 64 KWQRetain(other._NSFont); 62 65 KWQRelease(_NSFont); … … 147 150 } 148 151 149 bool QFont::isFixedPitch() const152 void QFont::determinePitch() const 150 153 { 151 154 KWQ_BLOCK_EXCEPTIONS; 152 return [[WebCoreTextRendererFactory sharedFactory] isFontFixedPitch: getNSFont()]; 155 if ([[WebCoreTextRendererFactory sharedFactory] isFontFixedPitch: getNSFont()]) 156 _pitch = Fixed; 157 else 158 _pitch = Variable; 153 159 KWQ_UNBLOCK_EXCEPTIONS; 154 return false;155 160 } 156 157 161 158 162 bool QFont::operator==(const QFont &compareFont) const … … 161 165 && _trait == compareFont._trait 162 166 && _size == compareFont._size 163 && _isPrinterFont == compareFont._isPrinterFont; 167 && _isPrinterFont == compareFont._isPrinterFont 168 && _pitch == compareFont._pitch; 164 169 } 165 170 -
trunk/WebCore/kwq/KWQKHTMLPart.cpp
r3930 r9639 33 33 using DOM::DocumentImpl; 34 34 using DOM::HTMLDocumentImpl; 35 using DOM::HTMLNames; 35 36 using DOM::NodeImpl; 36 37 38 // FIXME: What on earth is this single tiny file with only this method doing here? 37 39 bool KWQKHTMLPart::isFrameSet() const 38 40 { … … 41 43 return false; 42 44 NodeImpl *body = static_cast<HTMLDocumentImpl *>(document)->body(); 43 return body && body->renderer() && body-> id() == ID_FRAMESET;45 return body && body->renderer() && body->hasTagName(HTMLNames::frameset()); 44 46 } -
trunk/WebCore/kwq/KWQKHTMLPart.mm
r9619 r9639 29 29 30 30 #import "KWQClipboard.h" 31 #import "KWQDOMNode.h"32 31 #import "KWQDummyView.h" 33 32 #import "KWQEditCommand.h" … … 101 100 using DOM::HTMLFrameElementImpl; 102 101 using DOM::HTMLGenericFormElementImpl; 102 using DOM::HTMLNames; 103 103 using DOM::HTMLTableCellElementImpl; 104 104 using DOM::Node; … … 365 365 NodeImpl *n; 366 366 for (n = start; n; n = n->traverseNextNode()) { 367 NodeImpl::Id nodeID = idFromNode(n); 368 if (nodeID == ID_FORM) { 367 if (n->hasTagName(HTMLNames::form())) { 369 368 return static_cast<HTMLFormElementImpl *>(n); 370 369 } else if (n->isHTMLElement() 371 370 && static_cast<HTMLElementImpl *>(n)->isGenericFormElement()) { 372 371 return static_cast<HTMLGenericFormElementImpl *>(n)->form(); 373 } else if (n odeID == ID_FRAME || nodeID == ID_IFRAME) {372 } else if (n->hasTagName(HTMLNames::frame()) || n->hasTagName(HTMLNames::iframe())) { 374 373 NodeImpl *childDoc = static_cast<HTMLFrameElementImpl *>(n)->contentDocument(); 375 374 HTMLFormElementImpl *frameResult = scanForForm(childDoc); … … 394 393 NodeImpl *n; 395 394 for (n = start; n; n = n->parentNode()) { 396 if ( idFromNode(n) == ID_FORM) {395 if (n->hasTagName(HTMLNames::form())) { 397 396 return static_cast<HTMLFormElementImpl *>(n); 398 397 } else if (n->isHTMLElement() … … 493 492 // search within the above cell we found for a match 494 493 for (NodeImpl *n = aboveCell->firstChild(); n; n = n->traverseNextNode(aboveCell)) { 495 if (idFromNode(n) == ID_TEXT 496 && n->renderer() && n->renderer()->style()->visibility() == VISIBLE) 494 if (n->isTextNode() && n->renderer() && n->renderer()->style()->visibility() == VISIBLE) 497 495 { 498 496 // For each text chunk, run the regexp … … 529 527 n = n->traversePreviousNode()) 530 528 { 531 NodeImpl::Id nodeID = idFromNode(n); 532 if (nodeID == ID_FORM 529 if (n->hasTagName(HTMLNames::form()) 533 530 || (n->isHTMLElement() 534 531 && static_cast<HTMLElementImpl *>(n)->isGenericFormElement())) … … 536 533 // We hit another form element or the start of the form - bail out 537 534 break; 538 } else if (n odeID == ID_TD&& !startingTableCell) {535 } else if (n->hasTagName(HTMLNames::td()) && !startingTableCell) { 539 536 startingTableCell = static_cast<HTMLTableCellElementImpl *>(n); 540 } else if (n odeID == ID_TR&& startingTableCell) {537 } else if (n->hasTagName(HTMLNames::tr()) && startingTableCell) { 541 538 NSString *result = searchForLabelsAboveCell(regExp, startingTableCell); 542 539 if (result) { … … 544 541 } 545 542 searchedCellAbove = true; 546 } else if (nodeID == ID_TEXT 547 && n->renderer() && n->renderer()->style()->visibility() == VISIBLE) 543 } else if (n->isTextNode() && n->renderer() && n->renderer()->style()->visibility() == VISIBLE) 548 544 { 549 545 // For each text chunk, run the regexp … … 2852 2848 static ElementImpl *listParent(ElementImpl *item) 2853 2849 { 2854 // Ick! Avoid use of item->id() which confuses ObjC++. 2855 unsigned short _id = item->identifier(); 2856 2857 while (_id != ID_UL && _id != ID_OL) { 2850 while (!item->hasTagName(HTMLNames::ul()) && !item->hasTagName(HTMLNames::ol())) { 2858 2851 item = static_cast<ElementImpl *>(item->parentNode()); 2859 2852 if (!item) 2860 2853 break; 2861 _id = item->identifier();2862 2854 } 2863 2855 return item; … … 2872 2864 if (par->firstChild() != e) 2873 2865 return 0; 2874 if (par-> identifier() == ID_LI)2866 if (par->hasTagName(HTMLNames::li())) 2875 2867 return par; 2876 2868 e = par; … … 3026 3018 // This is our simple HTML -> ASCII transformation: 3027 3019 QString text; 3028 NodeImpl::Id _id = n->identifier(); 3029 switch(_id) { 3030 case ID_A: 3031 // Note the start of the <a> element. We will add the NSLinkAttributeName 3032 // attribute to the attributed string when navigating to the next sibling 3033 // of this node. 3034 linkStartLocation = [result length]; 3035 linkStartNode = static_cast<ElementImpl*>(n); 3036 break; 3037 3038 case ID_BR: 3039 text += "\n"; 3040 hasNewLine = true; 3041 break; 3042 3043 case ID_LI: 3044 { 3045 QString listText; 3046 ElementImpl *itemParent = listParent(static_cast<ElementImpl *>(n)); 3047 3048 if (!hasNewLine) 3049 listText += '\n'; 3050 hasNewLine = true; 3051 3052 listItems.append(static_cast<ElementImpl*>(n)); 3053 ListItemInfo info; 3054 info.start = [result length]; 3055 info.end = 0; 3056 listItemLocations.append (info); 3057 3058 listText += '\t'; 3059 if (itemParent && renderer->isListItem()) { 3060 RenderListItem *listRenderer = static_cast<RenderListItem*>(renderer); 3061 3062 maxMarkerWidth = MAX([font pointSize], maxMarkerWidth); 3063 switch(style->listStyleType()) { 3064 case khtml::DISC: 3065 listText += ((QChar)BULLET_CHAR); 3066 break; 3067 case khtml::CIRCLE: 3068 listText += ((QChar)CIRCLE_CHAR); 3069 break; 3070 case khtml::SQUARE: 3071 listText += ((QChar)SQUARE_CHAR); 3072 break; 3073 case khtml::LNONE: 3074 break; 3075 default: 3076 QString marker = listRenderer->markerStringValue(); 3077 listText += marker; 3078 // Use AppKit metrics. Will be rendered by AppKit. 3079 float markerWidth = [font widthOfString: marker.getNSString()]; 3080 maxMarkerWidth = MAX(markerWidth, maxMarkerWidth); 3081 } 3082 3083 listText += ' '; 3084 listText += '\t'; 3085 3086 NSMutableDictionary *attrs; 3087 3088 attrs = [[NSMutableDictionary alloc] init]; 3089 [attrs setObject:font forKey:NSFontAttributeName]; 3090 if (style && style->color().isValid()) 3091 [attrs setObject:nsColor(style->color()) forKey:NSForegroundColorAttributeName]; 3092 if (style && style->backgroundColor().isValid()) 3093 [attrs setObject:nsColor(style->backgroundColor()) forKey:NSBackgroundColorAttributeName]; 3094 3095 NSAttributedString *partialString = [[NSAttributedString alloc] initWithString:listText.getNSString() attributes:attrs]; 3096 [attrs release]; 3097 [result appendAttributedString: partialString]; 3098 [partialString release]; 3099 } 3020 if (n->hasTagName(HTMLNames::a())) { 3021 // Note the start of the <a> element. We will add the NSLinkAttributeName 3022 // attribute to the attributed string when navigating to the next sibling 3023 // of this node. 3024 linkStartLocation = [result length]; 3025 linkStartNode = static_cast<ElementImpl*>(n); 3026 } else if (n->hasTagName(HTMLNames::br())) { 3027 text += "\n"; 3028 hasNewLine = true; 3029 } else if (n->hasTagName(HTMLNames::li())) { 3030 QString listText; 3031 ElementImpl *itemParent = listParent(static_cast<ElementImpl *>(n)); 3032 3033 if (!hasNewLine) 3034 listText += '\n'; 3035 hasNewLine = true; 3036 3037 listItems.append(static_cast<ElementImpl*>(n)); 3038 ListItemInfo info; 3039 info.start = [result length]; 3040 info.end = 0; 3041 listItemLocations.append (info); 3042 3043 listText += '\t'; 3044 if (itemParent && renderer->isListItem()) { 3045 RenderListItem *listRenderer = static_cast<RenderListItem*>(renderer); 3046 3047 maxMarkerWidth = MAX([font pointSize], maxMarkerWidth); 3048 switch(style->listStyleType()) { 3049 case khtml::DISC: 3050 listText += ((QChar)BULLET_CHAR); 3051 break; 3052 case khtml::CIRCLE: 3053 listText += ((QChar)CIRCLE_CHAR); 3054 break; 3055 case khtml::SQUARE: 3056 listText += ((QChar)SQUARE_CHAR); 3057 break; 3058 case khtml::LNONE: 3059 break; 3060 default: 3061 QString marker = listRenderer->markerStringValue(); 3062 listText += marker; 3063 // Use AppKit metrics. Will be rendered by AppKit. 3064 float markerWidth = [font widthOfString: marker.getNSString()]; 3065 maxMarkerWidth = MAX(markerWidth, maxMarkerWidth); 3100 3066 } 3101 break; 3102 3103 case ID_OL: 3104 case ID_UL: 3067 3068 listText += ' '; 3069 listText += '\t'; 3070 3071 NSMutableDictionary *attrs = [[NSMutableDictionary alloc] init]; 3072 [attrs setObject:font forKey:NSFontAttributeName]; 3073 if (style && style->color().isValid()) 3074 [attrs setObject:nsColor(style->color()) forKey:NSForegroundColorAttributeName]; 3075 if (style && style->backgroundColor().isValid()) 3076 [attrs setObject:nsColor(style->backgroundColor()) forKey:NSBackgroundColorAttributeName]; 3077 3078 NSAttributedString *partialString = [[NSAttributedString alloc] initWithString:listText.getNSString() attributes:attrs]; 3079 [attrs release]; 3080 [result appendAttributedString: partialString]; 3081 [partialString release]; 3082 } 3083 else if (n->hasTagName(HTMLNames::ol()) || n->hasTagName(HTMLNames::ul())) { 3105 3084 if (!hasNewLine) 3106 3085 text += "\n"; 3107 3086 hasNewLine = true; 3108 break; 3109 3110 case ID_TD: 3111 case ID_TH: 3112 case ID_HR: 3113 case ID_DD: 3114 case ID_DL: 3115 case ID_DT: 3116 case ID_PRE: 3117 case ID_BLOCKQUOTE: 3118 case ID_DIV: 3087 } else if (n->hasTagName(HTMLNames::td()) || 3088 n->hasTagName(HTMLNames::th()) || 3089 n->hasTagName(HTMLNames::hr()) || 3090 n->hasTagName(HTMLNames::dd()) || 3091 n->hasTagName(HTMLNames::dl()) || 3092 n->hasTagName(HTMLNames::dt()) || 3093 n->hasTagName(HTMLNames::pre()) || 3094 n->hasTagName(HTMLNames::blockquote()) || 3095 n->hasTagName(HTMLNames::div())) { 3119 3096 if (!hasNewLine) 3120 3097 text += '\n'; 3121 3098 hasNewLine = true; 3122 break; 3123 case ID_P: 3124 case ID_TR: 3125 case ID_H1: 3126 case ID_H2: 3127 case ID_H3: 3128 case ID_H4: 3129 case ID_H5: 3130 case ID_H6: { 3099 } else if (n->hasTagName(HTMLNames::p()) || 3100 n->hasTagName(HTMLNames::tr()) || 3101 n->hasTagName(HTMLNames::h1()) || 3102 n->hasTagName(HTMLNames::h2()) || 3103 n->hasTagName(HTMLNames::h3()) || 3104 n->hasTagName(HTMLNames::h4()) || 3105 n->hasTagName(HTMLNames::h5()) || 3106 n->hasTagName(HTMLNames::h6())) { 3131 3107 if (!hasNewLine) 3132 3108 text += '\n'; … … 3143 3119 3144 3120 hasNewLine = true; 3145 break;3146 3121 } 3147 3148 case ID_IMG: 3122 else if (n->hasTagName(HTMLNames::img())) { 3149 3123 if (pendingStyledSpace != nil) { 3150 3124 if (linkStartLocation == [result length]) { … … 3160 3134 [result appendAttributedString: iString]; 3161 3135 [attachment release]; 3162 break;3136 } 3163 3137 } 3138 3164 3139 NSAttributedString *partialString = [[NSAttributedString alloc] initWithString:text.getNSString()]; 3165 3140 [result appendAttributedString: partialString]; … … 3183 3158 next = n->nextSibling(); 3184 3159 3185 NodeImpl::Id _id = n->identifier(); 3186 switch(_id) { 3187 case ID_A: 3188 // End of a <a> element. Create an attributed string NSLinkAttributeName attribute 3189 // for the range of the link. Note that we create the attributed string from the DOM, which 3190 // will have corrected any illegally nested <a> elements. 3191 if (linkStartNode && n == linkStartNode){ 3192 DOMString href = parseURL(linkStartNode->getAttribute(ATTR_HREF)); 3193 KURL kURL = KWQ(linkStartNode->getDocument()->part())->completeURL(href.string()); 3194 3195 NSURL *URL = kURL.getNSURL(); 3196 [result addAttribute:NSLinkAttributeName value:URL range:NSMakeRange(linkStartLocation, [result length]-linkStartLocation)]; 3197 linkStartNode = 0; 3160 if (n->hasTagName(HTMLNames::a())) { 3161 // End of a <a> element. Create an attributed string NSLinkAttributeName attribute 3162 // for the range of the link. Note that we create the attributed string from the DOM, which 3163 // will have corrected any illegally nested <a> elements. 3164 if (linkStartNode && n == linkStartNode) { 3165 DOMString href = parseURL(linkStartNode->getAttribute(ATTR_HREF)); 3166 KURL kURL = KWQ(linkStartNode->getDocument()->part())->completeURL(href.string()); 3167 3168 NSURL *URL = kURL.getNSURL(); 3169 [result addAttribute:NSLinkAttributeName value:URL range:NSMakeRange(linkStartLocation, [result length]-linkStartLocation)]; 3170 linkStartNode = 0; 3171 } 3172 } 3173 else if (n->hasTagName(HTMLNames::ol()) || n->hasTagName(HTMLNames::ul())) { 3174 if (!hasNewLine) 3175 text += '\n'; 3176 hasNewLine = true; 3177 } else if (n->hasTagName(HTMLNames::li())) { 3178 3179 int i, count = listItems.count(); 3180 for (i = 0; i < count; i++){ 3181 if (listItems.at(i) == n){ 3182 listItemLocations[i].end = [result length]; 3183 break; 3198 3184 } 3199 break; 3200 3201 case ID_OL: 3202 case ID_UL: 3203 if (!hasNewLine) 3204 text += '\n'; 3205 hasNewLine = true; 3206 break; 3207 3208 case ID_LI: 3209 { 3210 int i, count = listItems.count(); 3211 for (i = 0; i < count; i++){ 3212 if (listItems.at(i) == n){ 3213 listItemLocations[i].end = [result length]; 3214 break; 3215 } 3216 } 3217 } 3218 if (!hasNewLine) 3219 text += '\n'; 3220 hasNewLine = true; 3221 break; 3222 3223 case ID_TD: 3224 case ID_TH: 3225 case ID_HR: 3226 case ID_DD: 3227 case ID_DL: 3228 case ID_DT: 3229 case ID_PRE: 3230 case ID_BLOCKQUOTE: 3231 case ID_DIV: 3232 if (!hasNewLine) 3233 text += '\n'; 3234 hasNewLine = true; 3235 break; 3236 case ID_P: 3237 case ID_TR: 3238 case ID_H1: 3239 case ID_H2: 3240 case ID_H3: 3241 case ID_H4: 3242 case ID_H5: 3243 case ID_H6: 3244 if (!hasNewLine) 3245 text += '\n'; 3246 // An extra newline is needed at the start, not the end, of these types of tags, 3247 // so don't add another here. 3248 hasNewLine = true; 3249 break; 3185 } 3186 if (!hasNewLine) 3187 text += '\n'; 3188 hasNewLine = true; 3189 } else if (n->hasTagName(HTMLNames::td()) || 3190 n->hasTagName(HTMLNames::th()) || 3191 n->hasTagName(HTMLNames::hr()) || 3192 n->hasTagName(HTMLNames::dd()) || 3193 n->hasTagName(HTMLNames::dl()) || 3194 n->hasTagName(HTMLNames::dt()) || 3195 n->hasTagName(HTMLNames::pre()) || 3196 n->hasTagName(HTMLNames::blockquote()) || 3197 n->hasTagName(HTMLNames::div())) { 3198 if (!hasNewLine) 3199 text += '\n'; 3200 hasNewLine = true; 3201 } else if (n->hasTagName(HTMLNames::p()) || 3202 n->hasTagName(HTMLNames::tr()) || 3203 n->hasTagName(HTMLNames::h1()) || 3204 n->hasTagName(HTMLNames::h2()) || 3205 n->hasTagName(HTMLNames::h3()) || 3206 n->hasTagName(HTMLNames::h4()) || 3207 n->hasTagName(HTMLNames::h5()) || 3208 n->hasTagName(HTMLNames::h6())) { 3209 if (!hasNewLine) 3210 text += '\n'; 3211 // An extra newline is needed at the start, not the end, of these types of tags, 3212 // so don't add another here. 3213 hasNewLine = true; 3250 3214 } 3251 3215 … … 3480 3444 3481 3445 int exceptionCode = 0; 3482 ElementImpl *styleElement = xmlDocImpl()->create HTMLElement("span", exceptionCode);3446 ElementImpl *styleElement = xmlDocImpl()->createElementNS(HTMLNames::xhtmlNamespaceURI(), "span", exceptionCode); 3483 3447 ASSERT(exceptionCode == 0); 3484 3448 … … 3707 3671 // Look for a block flow, but skip over the HTML element, since we really 3708 3672 // want to get at least as far as the the BODY element in a document. 3709 if (node->isBlockFlow() && node-> identifier() != ID_HTML)3673 if (node->isBlockFlow() && node->hasTagName(HTMLNames::html())) 3710 3674 break; 3711 3675 node = node->traverseNextNode(); -
trunk/WebCore/kwq/KWQRenderTreeDebug.cpp
r9174 r9639 28 28 #include "dom_docimpl.h" 29 29 #include "dom_position.h" 30 #include "htmltags.h"31 30 #include "jsediting.h" 32 31 #include "khtmlview.h" … … 117 116 if (n->isDocumentNode()) 118 117 return ""; 119 if (n->id() <= ID_LAST_TAG) 120 return getTagName(n->id()).string(); 121 return n->nodeName().string(); 118 if (n->isTextNode()) 119 return "TEXT"; // FIXME: Remove once the layout tests are ready to change. 120 if (n->isCommentNode()) 121 return "COMMENT"; 122 if (n->isHTMLElement()) 123 return n->nodeName().upper().string(); // FIXME: We want to dump the real DOM name, not an uppercase name. 124 return n->nodeName().string(); 122 125 } 123 126 -
trunk/WebCore/kwq/WebCoreBridge.mm
r9611 r9639 40 40 #import "htmlattrs.h" 41 41 #import "htmlediting.h" 42 #import "htmltags.h"43 42 #import "khtml_part.h" 44 43 #import "khtmlview.h" … … 68 67 #import "KWQCharsets.h" 69 68 #import "KWQClipboard.h" 70 #import "KWQDOMNode.h"71 69 #import "KWQEditCommand.h" 72 70 #import "KWQFont.h" … … 101 99 using DOM::HTMLImageElementImpl; 102 100 using DOM::HTMLInputElementImpl; 101 using DOM::HTMLNames; 103 102 using DOM::NodeImpl; 104 103 using DOM::Position; … … 914 913 { 915 914 NodeImpl *node = [element _nodeImpl]; 916 if (node && idFromNode(node) == ID_INPUT) {915 if (node->hasTagName(HTMLNames::input())) { 917 916 return static_cast<HTMLInputElementImpl *>(node); 918 917 } … … 927 926 // that contains <form> elements that aren't in any namespace, so 928 927 // they come out as generic CML elements 929 if (node && node-> isHTMLElement() && idFromNode(node) == ID_FORM) {928 if (node && node->hasTagName(HTMLNames::form())) { 930 929 return static_cast<HTMLFormElementImpl *>(node); 931 930 } … … 1097 1096 // FIXME: Code copied from RenderImage::updateFromElement; should share. 1098 1097 DOMString attr; 1099 if (i dFromNode(i) == ID_OBJECT) {1098 if (i->hasTagName(HTMLNames::object())) { 1100 1099 attr = i->getAttribute(ATTR_DATA); 1101 1100 } else { … … 1109 1108 // FIXME: Code copied from RenderImage::updateFromElement; should share. 1110 1109 DOMString alt; 1111 if (i dFromNode(i) == ID_INPUT)1110 if (i->hasTagName(HTMLNames::input())) 1112 1111 alt = static_cast<HTMLInputElementImpl *>(i)->altText(); 1113 else if (i dFromNode(i) == ID_IMG)1112 else if (i->hasTagName(HTMLNames::img())) 1114 1113 alt = static_cast<HTMLImageElementImpl *>(i)->altText(); 1115 1114 if (!alt.isNull()) {
Note:
See TracChangeset
for help on using the changeset viewer.