[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

gramps gramps at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:56:55 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 36915ad9670398f3d31ab185415842173307a960
Author: gramps <gramps at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Mar 6 17:47:46 2002 +0000

    	Added APPLE_CHANGES define for compiling our changes to kdelibs.
    
    	Cleaned up all our changes to kdelibs, removed bitrot, and replaced use
    	of _KWQ_ with new APPLE_CHANGES define.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@702 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 8b68c4d..6b48bf8 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,94 @@
+2002-03-06  Don Melton  <gramps at apple.com>
+
+	Cleaned up all our changes to kdelibs, removed bitrot, and replaced use
+	of _KWQ_ with new APPLE_CHANGES define.
+
+	* src/kdelibs/khtml/css/csshelper.cpp: (khtml::computeLengthFloat),
+	(khtml::setFontSize):
+	* src/kdelibs/khtml/css/cssstyleselector.cpp:
+	(CSSStyleSelector::CSSStyleSelector), (khtml::applyRule):
+	* src/kdelibs/khtml/dom/dom_misc.cpp:
+	* src/kdelibs/khtml/dom/dom_misc.h:
+	* src/kdelibs/khtml/dom/html_document.cpp: (HTMLDocument::cookie),
+	(HTMLDocument::setCookie):
+	* src/kdelibs/khtml/dom/html_element.cpp:
+	* src/kdelibs/khtml/ecma/kjs_binding.h:
+	* src/kdelibs/khtml/ecma/kjs_css.cpp: (DOMCSSStyleDeclarationFunc::tryExecute),
+	(DOMStyleSheetListFunc::tryExecute), (DOMMediaListFunc::tryExecute),
+	(DOMCSSStyleSheetFunc::tryExecute), (DOMCSSRuleListFunc::tryExecute),
+	(DOMCSSRuleFunc::tryExecute), (DOMCSSPrimitiveValueFunc::tryExecute),
+	(DOMCSSValueListFunc::tryExecute):
+	* src/kdelibs/khtml/ecma/kjs_css.h:
+	* src/kdelibs/khtml/ecma/kjs_dom.cpp: (DOMNodeFunc::tryExecute),
+	(DOMNodeListFunc::tryExecute), (DOMDocFunction::DOMDocFunction),
+	(DOMDocFunction::tryExecute), (DOMElementFunction::DOMElementFunction),
+	(DOMElementFunction::tryExecute),
+	(DOMDOMImplementationFunction::DOMDOMImplementationFunction),
+	(DOMDOMImplementationFunction::tryExecute),
+	(DOMNamedNodeMapFunction::DOMNamedNodeMapFunction),
+	(DOMNamedNodeMapFunction::tryExecute):
+	* src/kdelibs/khtml/ecma/kjs_dom.h:
+	* src/kdelibs/khtml/ecma/kjs_window.cpp: (Window::isSafeScript):
+	* src/kdelibs/khtml/html/html_formimpl.cpp: (HTMLFormElementImpl::formData),
+	(HTMLSelectElementImpl::state), (HTMLSelectElementImpl::restoreState):
+	* src/kdelibs/khtml/html/html_headimpl.cpp: (HTMLLinkElementImpl::detach),
+	(HTMLStyleElementImpl::detach), (HTMLTitleElementImpl::setTitle):
+	* src/kdelibs/khtml/html/html_objectimpl.cpp:
+	(HTMLEmbedElementImpl::parseAttribute):
+	* src/kdelibs/khtml/html/html_tableimpl.cpp:
+	(HTMLTableElementImpl::parseAttribute),
+	(HTMLTablePartElementImpl::parseAttribute):
+	* src/kdelibs/khtml/html/htmlparser.cpp: (KHTMLParser::parseToken),
+	(KHTMLParser::insertNode), (KHTMLParser::getElement),
+	(KHTMLParser::processCloseTag), (KHTMLParser::popBlock),
+	(KHTMLParser::popOneBlock):
+	* src/kdelibs/khtml/html/htmltokenizer.cpp: (HTMLTokenizer::parseSpecial),
+	(HTMLTokenizer::scriptHandler), (HTMLTokenizer::parseComment),
+	(HTMLTokenizer::parseTag), (HTMLTokenizer::processToken):
+	* src/kdelibs/khtml/html/htmltokenizer.h:
+	* src/kdelibs/khtml/java/kjavaprocess.h:
+	* src/kdelibs/khtml/khtml_part.h:
+	* src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::~KHTMLView), (KHTMLView::init),
+	(printRenderTree), (KHTMLView::drawContents), (KHTMLView::layout),
+	(KHTMLView::viewportMousePressEvent), (KHTMLView::viewportMouseDoubleClickEvent),
+	(KHTMLView::viewportMouseMoveEvent), (KHTMLView::viewportMouseReleaseEvent),
+	(KHTMLView::addFormCompletionItem):
+	* src/kdelibs/khtml/khtmlview.h:
+	* src/kdelibs/khtml/misc/decoder.cpp: (Decoder::setEncoding), (Decoder::decode):
+	* src/kdelibs/khtml/misc/helper.cpp: (khtml::setNamedColor):
+	* src/kdelibs/khtml/misc/loader.h:
+	* src/kdelibs/khtml/rendering/bidi.cpp: (RenderFlow::layoutInlineChildren):
+	* src/kdelibs/khtml/rendering/render_applet.cpp: (RenderApplet::RenderApplet):
+	* src/kdelibs/khtml/rendering/render_body.cpp: (RenderBody::layout):
+	* src/kdelibs/khtml/rendering/render_box.cpp: (RenderBox::printBackground):
+	* src/kdelibs/khtml/rendering/render_flow.cpp: (RenderFlow::print):
+	* src/kdelibs/khtml/rendering/render_form.cpp:
+	(RenderFormElement::baselinePosition), (RenderFormElement::slotClicked),
+	(RenderCheckBox::RenderCheckBox), (RenderCheckBox::performAction),
+	(RenderRadioButton::RenderRadioButton), (RenderRadioButton::slotClicked),
+	(RenderSubmitButton::RenderSubmitButton), (RenderSubmitButton::baselinePosition),
+	(RenderLineEdit::RenderLineEdit), (RenderLineEdit::calcMinMaxWidth),
+	(RenderLineEdit::performAction), (RenderFileButton::RenderFileButton),
+	(RenderSelect::RenderSelect), (RenderSelect::layout),
+	(RenderSelect::createListBox), (RenderSelect::createComboBox),
+	(RenderTextArea::RenderTextArea), (RenderTextArea::calcMinMaxWidth),
+	(RenderTextArea::layout):
+	* src/kdelibs/khtml/rendering/render_form.h:
+	* src/kdelibs/khtml/rendering/render_frames.cpp:
+	(RenderPartObject::updateWidget):
+	* src/kdelibs/khtml/rendering/render_hr.cpp: (RenderHR::print):
+	* src/kdelibs/khtml/rendering/render_image.cpp: (RenderImage::printObject):
+	* src/kdelibs/khtml/rendering/render_list.cpp: (RenderListMarker::printObject):
+	* src/kdelibs/khtml/rendering/render_style.h:
+	* src/kdelibs/khtml/rendering/render_table.cpp: (RenderTable::calcFinalColMax),
+	(RenderTable::layoutRows):
+	* src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration),
+	(TextSlaveArray::findFirstMatching), (RenderText::print):
+	* src/kdelibs/khtml/xml/dom_docimpl.cpp: (DocumentImpl::recalcStyle):
+	* src/kdelibs/khtml/xml/dom_nodeimpl.cpp: (NodeImpl::renderer):
+	* src/kdelibs/khtml/xml/dom_nodeimpl.h:
+	* src/kdelibs/khtml/xml/dom_stringimpl.cpp: (DOMStringImpl::toLengthList):
+
 2002-03-06  Maciej Stachowiak  <mjs at apple.com>
 
 	* src/kwq/KWQKURL.mm: (KURL::KURL): If resolving a relative URL
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 8b68c4d..6b48bf8 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,94 @@
+2002-03-06  Don Melton  <gramps at apple.com>
+
+	Cleaned up all our changes to kdelibs, removed bitrot, and replaced use
+	of _KWQ_ with new APPLE_CHANGES define.
+
+	* src/kdelibs/khtml/css/csshelper.cpp: (khtml::computeLengthFloat),
+	(khtml::setFontSize):
+	* src/kdelibs/khtml/css/cssstyleselector.cpp:
+	(CSSStyleSelector::CSSStyleSelector), (khtml::applyRule):
+	* src/kdelibs/khtml/dom/dom_misc.cpp:
+	* src/kdelibs/khtml/dom/dom_misc.h:
+	* src/kdelibs/khtml/dom/html_document.cpp: (HTMLDocument::cookie),
+	(HTMLDocument::setCookie):
+	* src/kdelibs/khtml/dom/html_element.cpp:
+	* src/kdelibs/khtml/ecma/kjs_binding.h:
+	* src/kdelibs/khtml/ecma/kjs_css.cpp: (DOMCSSStyleDeclarationFunc::tryExecute),
+	(DOMStyleSheetListFunc::tryExecute), (DOMMediaListFunc::tryExecute),
+	(DOMCSSStyleSheetFunc::tryExecute), (DOMCSSRuleListFunc::tryExecute),
+	(DOMCSSRuleFunc::tryExecute), (DOMCSSPrimitiveValueFunc::tryExecute),
+	(DOMCSSValueListFunc::tryExecute):
+	* src/kdelibs/khtml/ecma/kjs_css.h:
+	* src/kdelibs/khtml/ecma/kjs_dom.cpp: (DOMNodeFunc::tryExecute),
+	(DOMNodeListFunc::tryExecute), (DOMDocFunction::DOMDocFunction),
+	(DOMDocFunction::tryExecute), (DOMElementFunction::DOMElementFunction),
+	(DOMElementFunction::tryExecute),
+	(DOMDOMImplementationFunction::DOMDOMImplementationFunction),
+	(DOMDOMImplementationFunction::tryExecute),
+	(DOMNamedNodeMapFunction::DOMNamedNodeMapFunction),
+	(DOMNamedNodeMapFunction::tryExecute):
+	* src/kdelibs/khtml/ecma/kjs_dom.h:
+	* src/kdelibs/khtml/ecma/kjs_window.cpp: (Window::isSafeScript):
+	* src/kdelibs/khtml/html/html_formimpl.cpp: (HTMLFormElementImpl::formData),
+	(HTMLSelectElementImpl::state), (HTMLSelectElementImpl::restoreState):
+	* src/kdelibs/khtml/html/html_headimpl.cpp: (HTMLLinkElementImpl::detach),
+	(HTMLStyleElementImpl::detach), (HTMLTitleElementImpl::setTitle):
+	* src/kdelibs/khtml/html/html_objectimpl.cpp:
+	(HTMLEmbedElementImpl::parseAttribute):
+	* src/kdelibs/khtml/html/html_tableimpl.cpp:
+	(HTMLTableElementImpl::parseAttribute),
+	(HTMLTablePartElementImpl::parseAttribute):
+	* src/kdelibs/khtml/html/htmlparser.cpp: (KHTMLParser::parseToken),
+	(KHTMLParser::insertNode), (KHTMLParser::getElement),
+	(KHTMLParser::processCloseTag), (KHTMLParser::popBlock),
+	(KHTMLParser::popOneBlock):
+	* src/kdelibs/khtml/html/htmltokenizer.cpp: (HTMLTokenizer::parseSpecial),
+	(HTMLTokenizer::scriptHandler), (HTMLTokenizer::parseComment),
+	(HTMLTokenizer::parseTag), (HTMLTokenizer::processToken):
+	* src/kdelibs/khtml/html/htmltokenizer.h:
+	* src/kdelibs/khtml/java/kjavaprocess.h:
+	* src/kdelibs/khtml/khtml_part.h:
+	* src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::~KHTMLView), (KHTMLView::init),
+	(printRenderTree), (KHTMLView::drawContents), (KHTMLView::layout),
+	(KHTMLView::viewportMousePressEvent), (KHTMLView::viewportMouseDoubleClickEvent),
+	(KHTMLView::viewportMouseMoveEvent), (KHTMLView::viewportMouseReleaseEvent),
+	(KHTMLView::addFormCompletionItem):
+	* src/kdelibs/khtml/khtmlview.h:
+	* src/kdelibs/khtml/misc/decoder.cpp: (Decoder::setEncoding), (Decoder::decode):
+	* src/kdelibs/khtml/misc/helper.cpp: (khtml::setNamedColor):
+	* src/kdelibs/khtml/misc/loader.h:
+	* src/kdelibs/khtml/rendering/bidi.cpp: (RenderFlow::layoutInlineChildren):
+	* src/kdelibs/khtml/rendering/render_applet.cpp: (RenderApplet::RenderApplet):
+	* src/kdelibs/khtml/rendering/render_body.cpp: (RenderBody::layout):
+	* src/kdelibs/khtml/rendering/render_box.cpp: (RenderBox::printBackground):
+	* src/kdelibs/khtml/rendering/render_flow.cpp: (RenderFlow::print):
+	* src/kdelibs/khtml/rendering/render_form.cpp:
+	(RenderFormElement::baselinePosition), (RenderFormElement::slotClicked),
+	(RenderCheckBox::RenderCheckBox), (RenderCheckBox::performAction),
+	(RenderRadioButton::RenderRadioButton), (RenderRadioButton::slotClicked),
+	(RenderSubmitButton::RenderSubmitButton), (RenderSubmitButton::baselinePosition),
+	(RenderLineEdit::RenderLineEdit), (RenderLineEdit::calcMinMaxWidth),
+	(RenderLineEdit::performAction), (RenderFileButton::RenderFileButton),
+	(RenderSelect::RenderSelect), (RenderSelect::layout),
+	(RenderSelect::createListBox), (RenderSelect::createComboBox),
+	(RenderTextArea::RenderTextArea), (RenderTextArea::calcMinMaxWidth),
+	(RenderTextArea::layout):
+	* src/kdelibs/khtml/rendering/render_form.h:
+	* src/kdelibs/khtml/rendering/render_frames.cpp:
+	(RenderPartObject::updateWidget):
+	* src/kdelibs/khtml/rendering/render_hr.cpp: (RenderHR::print):
+	* src/kdelibs/khtml/rendering/render_image.cpp: (RenderImage::printObject):
+	* src/kdelibs/khtml/rendering/render_list.cpp: (RenderListMarker::printObject):
+	* src/kdelibs/khtml/rendering/render_style.h:
+	* src/kdelibs/khtml/rendering/render_table.cpp: (RenderTable::calcFinalColMax),
+	(RenderTable::layoutRows):
+	* src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration),
+	(TextSlaveArray::findFirstMatching), (RenderText::print):
+	* src/kdelibs/khtml/xml/dom_docimpl.cpp: (DocumentImpl::recalcStyle):
+	* src/kdelibs/khtml/xml/dom_nodeimpl.cpp: (NodeImpl::renderer):
+	* src/kdelibs/khtml/xml/dom_nodeimpl.h:
+	* src/kdelibs/khtml/xml/dom_stringimpl.cpp: (DOMStringImpl::toLengthList):
+
 2002-03-06  Maciej Stachowiak  <mjs at apple.com>
 
 	* src/kwq/KWQKURL.mm: (KURL::KURL): If resolving a relative URL
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 8b68c4d..6b48bf8 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,94 @@
+2002-03-06  Don Melton  <gramps at apple.com>
+
+	Cleaned up all our changes to kdelibs, removed bitrot, and replaced use
+	of _KWQ_ with new APPLE_CHANGES define.
+
+	* src/kdelibs/khtml/css/csshelper.cpp: (khtml::computeLengthFloat),
+	(khtml::setFontSize):
+	* src/kdelibs/khtml/css/cssstyleselector.cpp:
+	(CSSStyleSelector::CSSStyleSelector), (khtml::applyRule):
+	* src/kdelibs/khtml/dom/dom_misc.cpp:
+	* src/kdelibs/khtml/dom/dom_misc.h:
+	* src/kdelibs/khtml/dom/html_document.cpp: (HTMLDocument::cookie),
+	(HTMLDocument::setCookie):
+	* src/kdelibs/khtml/dom/html_element.cpp:
+	* src/kdelibs/khtml/ecma/kjs_binding.h:
+	* src/kdelibs/khtml/ecma/kjs_css.cpp: (DOMCSSStyleDeclarationFunc::tryExecute),
+	(DOMStyleSheetListFunc::tryExecute), (DOMMediaListFunc::tryExecute),
+	(DOMCSSStyleSheetFunc::tryExecute), (DOMCSSRuleListFunc::tryExecute),
+	(DOMCSSRuleFunc::tryExecute), (DOMCSSPrimitiveValueFunc::tryExecute),
+	(DOMCSSValueListFunc::tryExecute):
+	* src/kdelibs/khtml/ecma/kjs_css.h:
+	* src/kdelibs/khtml/ecma/kjs_dom.cpp: (DOMNodeFunc::tryExecute),
+	(DOMNodeListFunc::tryExecute), (DOMDocFunction::DOMDocFunction),
+	(DOMDocFunction::tryExecute), (DOMElementFunction::DOMElementFunction),
+	(DOMElementFunction::tryExecute),
+	(DOMDOMImplementationFunction::DOMDOMImplementationFunction),
+	(DOMDOMImplementationFunction::tryExecute),
+	(DOMNamedNodeMapFunction::DOMNamedNodeMapFunction),
+	(DOMNamedNodeMapFunction::tryExecute):
+	* src/kdelibs/khtml/ecma/kjs_dom.h:
+	* src/kdelibs/khtml/ecma/kjs_window.cpp: (Window::isSafeScript):
+	* src/kdelibs/khtml/html/html_formimpl.cpp: (HTMLFormElementImpl::formData),
+	(HTMLSelectElementImpl::state), (HTMLSelectElementImpl::restoreState):
+	* src/kdelibs/khtml/html/html_headimpl.cpp: (HTMLLinkElementImpl::detach),
+	(HTMLStyleElementImpl::detach), (HTMLTitleElementImpl::setTitle):
+	* src/kdelibs/khtml/html/html_objectimpl.cpp:
+	(HTMLEmbedElementImpl::parseAttribute):
+	* src/kdelibs/khtml/html/html_tableimpl.cpp:
+	(HTMLTableElementImpl::parseAttribute),
+	(HTMLTablePartElementImpl::parseAttribute):
+	* src/kdelibs/khtml/html/htmlparser.cpp: (KHTMLParser::parseToken),
+	(KHTMLParser::insertNode), (KHTMLParser::getElement),
+	(KHTMLParser::processCloseTag), (KHTMLParser::popBlock),
+	(KHTMLParser::popOneBlock):
+	* src/kdelibs/khtml/html/htmltokenizer.cpp: (HTMLTokenizer::parseSpecial),
+	(HTMLTokenizer::scriptHandler), (HTMLTokenizer::parseComment),
+	(HTMLTokenizer::parseTag), (HTMLTokenizer::processToken):
+	* src/kdelibs/khtml/html/htmltokenizer.h:
+	* src/kdelibs/khtml/java/kjavaprocess.h:
+	* src/kdelibs/khtml/khtml_part.h:
+	* src/kdelibs/khtml/khtmlview.cpp: (KHTMLView::~KHTMLView), (KHTMLView::init),
+	(printRenderTree), (KHTMLView::drawContents), (KHTMLView::layout),
+	(KHTMLView::viewportMousePressEvent), (KHTMLView::viewportMouseDoubleClickEvent),
+	(KHTMLView::viewportMouseMoveEvent), (KHTMLView::viewportMouseReleaseEvent),
+	(KHTMLView::addFormCompletionItem):
+	* src/kdelibs/khtml/khtmlview.h:
+	* src/kdelibs/khtml/misc/decoder.cpp: (Decoder::setEncoding), (Decoder::decode):
+	* src/kdelibs/khtml/misc/helper.cpp: (khtml::setNamedColor):
+	* src/kdelibs/khtml/misc/loader.h:
+	* src/kdelibs/khtml/rendering/bidi.cpp: (RenderFlow::layoutInlineChildren):
+	* src/kdelibs/khtml/rendering/render_applet.cpp: (RenderApplet::RenderApplet):
+	* src/kdelibs/khtml/rendering/render_body.cpp: (RenderBody::layout):
+	* src/kdelibs/khtml/rendering/render_box.cpp: (RenderBox::printBackground):
+	* src/kdelibs/khtml/rendering/render_flow.cpp: (RenderFlow::print):
+	* src/kdelibs/khtml/rendering/render_form.cpp:
+	(RenderFormElement::baselinePosition), (RenderFormElement::slotClicked),
+	(RenderCheckBox::RenderCheckBox), (RenderCheckBox::performAction),
+	(RenderRadioButton::RenderRadioButton), (RenderRadioButton::slotClicked),
+	(RenderSubmitButton::RenderSubmitButton), (RenderSubmitButton::baselinePosition),
+	(RenderLineEdit::RenderLineEdit), (RenderLineEdit::calcMinMaxWidth),
+	(RenderLineEdit::performAction), (RenderFileButton::RenderFileButton),
+	(RenderSelect::RenderSelect), (RenderSelect::layout),
+	(RenderSelect::createListBox), (RenderSelect::createComboBox),
+	(RenderTextArea::RenderTextArea), (RenderTextArea::calcMinMaxWidth),
+	(RenderTextArea::layout):
+	* src/kdelibs/khtml/rendering/render_form.h:
+	* src/kdelibs/khtml/rendering/render_frames.cpp:
+	(RenderPartObject::updateWidget):
+	* src/kdelibs/khtml/rendering/render_hr.cpp: (RenderHR::print):
+	* src/kdelibs/khtml/rendering/render_image.cpp: (RenderImage::printObject):
+	* src/kdelibs/khtml/rendering/render_list.cpp: (RenderListMarker::printObject):
+	* src/kdelibs/khtml/rendering/render_style.h:
+	* src/kdelibs/khtml/rendering/render_table.cpp: (RenderTable::calcFinalColMax),
+	(RenderTable::layoutRows):
+	* src/kdelibs/khtml/rendering/render_text.cpp: (TextSlave::printDecoration),
+	(TextSlaveArray::findFirstMatching), (RenderText::print):
+	* src/kdelibs/khtml/xml/dom_docimpl.cpp: (DocumentImpl::recalcStyle):
+	* src/kdelibs/khtml/xml/dom_nodeimpl.cpp: (NodeImpl::renderer):
+	* src/kdelibs/khtml/xml/dom_nodeimpl.h:
+	* src/kdelibs/khtml/xml/dom_stringimpl.cpp: (DOMStringImpl::toLengthList):
+
 2002-03-06  Maciej Stachowiak  <mjs at apple.com>
 
 	* src/kwq/KWQKURL.mm: (KURL::KURL): If resolving a relative URL
diff --git a/WebCore/khtml/css/csshelper.cpp b/WebCore/khtml/css/csshelper.cpp
index 515fcfa..dce46f3 100644
--- a/WebCore/khtml/css/csshelper.cpp
+++ b/WebCore/khtml/css/csshelper.cpp
@@ -54,10 +54,14 @@ float khtml::computeLengthFloat(DOM::CSSPrimitiveValueImpl *val, RenderStyle *st
     float dpiY = 72.; // fallback
     if ( devMetrics )
         dpiY = devMetrics->logicalDpiY();
-        
+#ifdef APPLE_CHANGES
     // FIXME: SCREEN_RESOLUTION hack good enough to keep?
     if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
         dpiY = SCREEN_RESOLUTION;
+#else /* APPLE_CHANGES not defined */
+    if ( !khtml::printpainter && dpiY < 96 )
+        dpiY = 96.;
+#endif /* APPLE_CHANGES not defined */
 
     float factor = 1.;
     switch(type)
@@ -143,11 +147,13 @@ DOMString khtml::parseURL(const DOMString &url)
 
 void khtml::setFontSize( QFont &f,  int  pixelsize, const KHTMLSettings *s, QPaintDeviceMetrics *devMetrics )
 {
-    float size = pixelsize;
-
-#ifndef _KWQ_
+#ifndef APPLE_CHANGES
     QFontDatabase db;
+#endif /* APPLE_CHANGES not defined */
 
+    float size = pixelsize;
+
+#ifndef APPLE_CHANGES
     float toPix = 1.;
     if ( !khtml::printpainter )
         toPix = devMetrics->logicalDpiY()/72.;
@@ -185,7 +191,8 @@ void khtml::setFontSize( QFont &f,  int  pixelsize, const KHTMLSettings *s, QPai
 //         else if ( size > 4 && size < 16 )
 //             size = float( int( ( size + 1 ) / 2 )*2 );
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
+
     //qDebug(" -->>> using %f pixel font", size);
 
     f.setPixelSizeFloat( size );
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 6354c50..9513da4 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -73,12 +73,11 @@ static int usedDynamicStates;
 static int selectorDynamicState;
 static CSSStyleSelector::Encodedurl *encodedurl;
 
+
 CSSStyleSelector::CSSStyleSelector(DocumentImpl * doc)
 {
     strictParsing = doc->parseMode() == DocumentImpl::Strict;
-    if(!defaultStyle){
-        loadDefaultStyle(doc->view()?doc->view()->part()->settings():0);
-    }
+    if(!defaultStyle) loadDefaultStyle(doc->view()?doc->view()->part()->settings():0);
 
     selectors = 0;
     selectorCache = 0;
@@ -1941,9 +1940,14 @@ void khtml::applyRule(khtml::RenderStyle *style, DOM::CSSProperty *prop, DOM::El
         float toPix = 1.; // fallback
         if ( !khtml::printpainter )
             toPix = paintDeviceMetrics->logicalDpiY()/72.;
+#ifdef APPLE_CHANGES
         // FIXME: SCREEN_RESOLUTION hack good enough to keep?
         if ( !khtml::printpainter && toPix < SCREEN_RESOLUTION/72 )
             toPix = SCREEN_RESOLUTION/72;
+#else /* APPLE_CHANGES not defined */
+        if ( !khtml::printpainter && toPix < 96./72. )
+            toPix = 96./72.;
+#endif /* APPLE_CHANGES not defined */
 
         QValueList<int> standardSizes = e->ownerDocument()->view()->part()->fontSizes();
         if(e->parentNode()) {
diff --git a/WebCore/khtml/dom/dom_misc.cpp b/WebCore/khtml/dom/dom_misc.cpp
index de664e1..3d6edd4 100644
--- a/WebCore/khtml/dom/dom_misc.cpp
+++ b/WebCore/khtml/dom/dom_misc.cpp
@@ -23,8 +23,9 @@
 
 #include "dom_misc.h"
 using namespace DOM;
-
+#ifdef APPLE_CHANGES
 #include <stdio.h>
+#endif /* APPLE_CHANGES */
 
 DomShared::~DomShared()
 {
@@ -38,7 +39,8 @@ bool DomShared::deleteMe()
   return false;
 }
 
-#ifdef _KWQ_
+
+#ifdef APPLE_CHANGES
 void *DomShared::instanceToCheck;
 
 void DomShared::ref()
@@ -59,4 +61,4 @@ void DomShared::deref()
     if(!_ref && deleteMe())
         delete this; 
 }
-#endif
+#endif /* APPLE_CHANGES */
diff --git a/WebCore/khtml/dom/dom_misc.h b/WebCore/khtml/dom/dom_misc.h
index 265b571..ea3f7af 100644
--- a/WebCore/khtml/dom/dom_misc.h
+++ b/WebCore/khtml/dom/dom_misc.h
@@ -32,7 +32,6 @@ namespace DOM {
  * Other objects should overload deleteMe() to fit their needs. The default
  * implementation deletes the object if the ref count drops to 0.
  */
- 
 class DomShared
 {
 public:
@@ -43,16 +42,15 @@ public:
    */
   virtual bool deleteMe();
 
-#ifndef _KWQ_
-  void ref() { _ref++; }
-  void deref() { if(_ref) _ref--; if(!_ref && deleteMe()) delete this; }
-#else
+#ifdef APPLE_CHANGES
   static void *instanceToCheck;
 
   void ref();
   void deref();
-#endif
-
+#else /* APPLE_CHANGES not defined */
+  void ref() { _ref++; }
+  void deref() { if(_ref) _ref--; if(!_ref && deleteMe()) delete this; }
+#endif /* APPLE_CHANGES not defined */
   // ###  KDE 3.0: add const
   bool hasOneRef() { return _ref == 1; }
   unsigned int refCount() const { return _ref; }
diff --git a/WebCore/khtml/dom/html_document.cpp b/WebCore/khtml/dom/html_document.cpp
index 91ab8e1..ede83ee 100644
--- a/WebCore/khtml/dom/html_document.cpp
+++ b/WebCore/khtml/dom/html_document.cpp
@@ -41,6 +41,7 @@
 #include "khtmlview.h"
 using namespace DOM;
 
+
 HTMLDocument::HTMLDocument() : Document(false) // create the impl here
 {
     impl = new HTMLDocumentImpl();
@@ -178,11 +179,11 @@ HTMLCollection HTMLDocument::all() const
 
 DOMString HTMLDocument::cookie() const
 {
+#ifdef APPLE_CHANGES
 // FIXME: implement cookies
-#ifdef _KWQ_
     fprintf(stderr, "ERROR %s:%d  %s (NOT YET IMPLEMENTED)\n", __FILE__, __LINE__, __FUNCTION__);
     return DOMString("");
-#else
+#else /* APPLE_CHANGES not defined */
     QCString replyType;
     QByteArray params, reply;
     QDataStream stream(params, IO_WriteOnly);
@@ -203,14 +204,14 @@ DOMString HTMLDocument::cookie() const
     QString result;
     stream2 >> result;
     return DOMString(result);
-#endif
+#endif /* APPLE_CHANGES not defined */
 }
 
 void HTMLDocument::setCookie( const DOMString & value )
 {
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     fprintf(stderr, "ERROR %s:%d  %s (NOT YET IMPLEMENTED)\n", __FILE__, __LINE__, __FUNCTION__);
-#else
+#else /* APPLE_CHANGES not defined */
     long windowId = view()->winId();
     QByteArray params;
     QDataStream stream(params, IO_WriteOnly);
@@ -223,7 +224,7 @@ void HTMLDocument::setCookie( const DOMString & value )
     {
 	 kdWarning(6010) << "Can't communicate with cookiejar!" << endl;
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
 }
 
 void HTMLDocument::open(  )
diff --git a/WebCore/khtml/dom/html_element.cpp b/WebCore/khtml/dom/html_element.cpp
index 1f8adcf..f5590ad 100644
--- a/WebCore/khtml/dom/html_element.cpp
+++ b/WebCore/khtml/dom/html_element.cpp
@@ -1,4 +1,4 @@
- /**
+/**
  * This file is part of the DOM implementation for KDE.
  *
  * (C) 1999 Lars Knoll (knoll at kde.org)
diff --git a/WebCore/khtml/ecma/kjs_binding.h b/WebCore/khtml/ecma/kjs_binding.h
index f426b69..a819809 100644
--- a/WebCore/khtml/ecma/kjs_binding.h
+++ b/WebCore/khtml/ecma/kjs_binding.h
@@ -26,7 +26,9 @@
 #include <dom/dom_doc.h>
 #include <kurl.h>
 #include <qguardedptr.h>
+#ifdef APPLE_CHANGES
 #include <qvariant.h>
+#endif /* APPLE_CHANGES */
 
 namespace KJS {
 
diff --git a/WebCore/khtml/ecma/kjs_css.cpp b/WebCore/khtml/ecma/kjs_css.cpp
index 32c74a5..5eae7cb 100644
--- a/WebCore/khtml/ecma/kjs_css.cpp
+++ b/WebCore/khtml/ecma/kjs_css.cpp
@@ -150,7 +150,7 @@ Completion DOMCSSStyleDeclarationFunc::tryExecute(const List &args)
   String str = args[0].toString();
   DOM::DOMString s = str.value().string();
 
-  switch (_id) {
+  switch (id) {
     case GetPropertyValue:
       result = getString(styleDecl.getPropertyValue(s));
       break;
@@ -294,7 +294,7 @@ Completion DOMStyleSheetListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  if (_id == Item)
+  if (id == Item)
     result = getDOMStyleSheet(styleSheetList.item(args[0].toNumber().intValue()));
   return Completion(ReturnValue, result);
 }
@@ -357,7 +357,7 @@ Completion DOMMediaListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case Item:
       result = getString(mediaList.item(args[0].toNumber().intValue()));
       break;
@@ -408,7 +408,7 @@ Completion DOMCSSStyleSheetFunc::tryExecute(const List &args)
   String str = args[0].toString();
   DOM::DOMString s = str.value().string();
 
-  switch (_id) {
+  switch (id) {
     case InsertRule:
       result = Number(styleSheet.insertRule(args[0].toString().value().string(),(long unsigned int)args[1].toNumber().intValue()));
       break;
@@ -452,7 +452,7 @@ Completion DOMCSSRuleListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case Item:
       result = getDOMCSSRule(cssRuleList.item(args[0].toNumber().intValue()));
       break;
@@ -586,9 +586,9 @@ Completion DOMCSSRuleFunc::tryExecute(const List &args)
 
   if (cssRule.type() == DOM::CSSRule::MEDIA_RULE) {
     DOM::CSSMediaRule rule = static_cast<DOM::CSSMediaRule>(cssRule);
-    if (_id == InsertRule)
+    if (id == InsertRule)
       result = Number(rule.insertRule(args[0].toString().value().string(),args[1].toNumber().intValue()));
-    else if (_id == DeleteRule)
+    else if (id == DeleteRule)
       rule.deleteRule(args[0].toNumber().intValue());
   }
 
@@ -773,7 +773,7 @@ Completion DOMCSSPrimitiveValueFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case SetFloatValue:
       val.setFloatValue(args[0].toNumber().intValue(),args[1].toNumber().value());
       result = Undefined();
@@ -879,7 +879,7 @@ Completion DOMCSSValueListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case Item:
       result = getDOMCSSValue(valueList.item(args[0].toNumber().intValue()));
       break;
diff --git a/WebCore/khtml/ecma/kjs_css.h b/WebCore/khtml/ecma/kjs_css.h
index b772fea..1d78212 100644
--- a/WebCore/khtml/ecma/kjs_css.h
+++ b/WebCore/khtml/ecma/kjs_css.h
@@ -28,6 +28,9 @@
 #include <dom/css_rule.h>
 #include "kjs_binding.h"
 
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#define id id_
+#endif /* APPLE_CHANGES, __OBJC__ */
 namespace KJS {
 
   class DOMCSSStyleDeclaration : public DOMObject {
@@ -46,13 +49,13 @@ namespace KJS {
   class DOMCSSStyleDeclarationFunc : public DOMFunction {
     friend class DOMNode;
   public:
-    DOMCSSStyleDeclarationFunc(DOM::CSSStyleDeclaration s, int i) : styleDecl(s), _id(i) { }
+    DOMCSSStyleDeclarationFunc(DOM::CSSStyleDeclaration s, int i) : styleDecl(s), id(i) { }
     Completion tryExecute(const List &);
     enum { GetPropertyValue, GetPropertyCSSValue, RemoveProperty, GetPropertyPriority,
            SetProperty, Item };
   private:
     DOM::CSSStyleDeclaration styleDecl;
-    int _id;
+    int id;
   };
 
   KJSO getDOMCSSStyleDeclaration(DOM::CSSStyleDeclaration n);
@@ -90,12 +93,12 @@ namespace KJS {
   class DOMStyleSheetListFunc : public DOMFunction {
     friend class DOMStyleSheetList;
   public:
-    DOMStyleSheetListFunc(DOM::StyleSheetList ssl, int i) : styleSheetList(ssl), _id(i) { }
+    DOMStyleSheetListFunc(DOM::StyleSheetList ssl, int i) : styleSheetList(ssl), id(i) { }
     Completion tryExecute(const List &);
     enum { Item };
   private:
     DOM::StyleSheetList styleSheetList;
-    int _id;
+    int id;
   };
 
   class DOMMediaList : public DOMObject {
@@ -116,12 +119,12 @@ namespace KJS {
   class DOMMediaListFunc : public DOMFunction {
     friend class DOMMediaList;
   public:
-    DOMMediaListFunc(DOM::MediaList ml, int i) : mediaList(ml), _id(i) { }
+    DOMMediaListFunc(DOM::MediaList ml, int i) : mediaList(ml), id(i) { }
     Completion tryExecute(const List &);
     enum { Item, DeleteMedium, AppendMedium };
   private:
     DOM::MediaList mediaList;
-    int _id;
+    int id;
   };
 
   class DOMCSSStyleSheet : public DOMStyleSheet {
@@ -137,12 +140,12 @@ namespace KJS {
   class DOMCSSStyleSheetFunc : public DOMFunction {
     friend class DOMNode;
   public:
-    DOMCSSStyleSheetFunc(DOM::CSSStyleSheet ss, int i) : styleSheet(ss), _id(i) { }
+    DOMCSSStyleSheetFunc(DOM::CSSStyleSheet ss, int i) : styleSheet(ss), id(i) { }
     Completion tryExecute(const List &);
     enum { InsertRule, DeleteRule };
   private:
     DOM::CSSStyleSheet styleSheet;
-    int _id;
+    int id;
   };
 
   class DOMCSSRuleList : public DOMObject {
@@ -159,12 +162,12 @@ namespace KJS {
 
   class DOMCSSRuleListFunc : public DOMFunction {
   public:
-    DOMCSSRuleListFunc(DOM::CSSRuleList rl, int i) : cssRuleList(rl), _id(i) { }
+    DOMCSSRuleListFunc(DOM::CSSRuleList rl, int i) : cssRuleList(rl), id(i) { }
     Completion tryExecute(const List &);
     enum { Item };
   private:
     DOM::CSSRuleList cssRuleList;
-    int _id;
+    int id;
   };
 
   KJSO getDOMCSSRuleList(DOM::CSSRuleList rl);
@@ -184,12 +187,12 @@ namespace KJS {
 
   class DOMCSSRuleFunc : public DOMFunction {
   public:
-    DOMCSSRuleFunc(DOM::CSSRule r, int i) : cssRule(r), _id(i) { }
+    DOMCSSRuleFunc(DOM::CSSRule r, int i) : cssRule(r), id(i) { }
     Completion tryExecute(const List &);
     enum { Item, InsertRule, DeleteRule };
   private:
     DOM::CSSRule cssRule;
-    int _id;
+    int id;
   };
 
   KJSO getDOMCSSRule(DOM::CSSRule r);
@@ -249,13 +252,13 @@ namespace KJS {
   class DOMCSSPrimitiveValueFunc : public DOMFunction {
     friend class DOMNode;
   public:
-    DOMCSSPrimitiveValueFunc(DOM::CSSPrimitiveValue v, int i) : val(v), _id(i) { }
+    DOMCSSPrimitiveValueFunc(DOM::CSSPrimitiveValue v, int i) : val(v), id(i) { }
     Completion tryExecute(const List &);
     enum { SetFloatValue, GetFloatValue, SetStringValue, GetStringValue,
            GetCounterValue, GetRectValue, GetRGBColorValue };
   private:
     DOM::CSSPrimitiveValue val;
-    int _id;
+    int id;
   };
 
   // Prototype object CSSPrimitiveValue
@@ -281,12 +284,12 @@ namespace KJS {
 
   class DOMCSSValueListFunc : public DOMFunction {
   public:
-    DOMCSSValueListFunc(DOM::CSSValueList vl, int i) : valueList(vl), _id(i) { }
+    DOMCSSValueListFunc(DOM::CSSValueList vl, int i) : valueList(vl), id(i) { }
     Completion tryExecute(const List &);
     enum { Item };
   private:
     DOM::CSSValueList valueList;
-    int _id;
+    int id;
   };
 
   class DOMRGBColor : public DOMObject {
@@ -332,5 +335,8 @@ namespace KJS {
   KJSO getDOMCounter(DOM::Counter c);
 
 }; // namespace
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#undef id
+#endif /* APPLE_CHANGES, __OBJC__ */
 
 #endif
diff --git a/WebCore/khtml/ecma/kjs_dom.cpp b/WebCore/khtml/ecma/kjs_dom.cpp
index 045e03c..bfcdbde 100644
--- a/WebCore/khtml/ecma/kjs_dom.cpp
+++ b/WebCore/khtml/ecma/kjs_dom.cpp
@@ -324,7 +324,7 @@ Completion DOMNodeFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case HasChildNodes:
       result = Boolean(node.hasChildNodes());
       break;
@@ -411,7 +411,7 @@ Completion DOMNodeListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  if (_id == Item)
+  if (id == Item)
     result = getDOMNode(list.item(args[0].toNumber().intValue()));
   return Completion(ReturnValue, result);
 }
@@ -528,7 +528,7 @@ KJSO DOMDocument::tryGet(const UString &p) const
 }
 
 DOMDocFunction::DOMDocFunction(DOM::Document d, int i)
-  : doc(d), _id(i)
+  : doc(d), id(i)
 {
 }
 
@@ -540,7 +540,7 @@ Completion DOMDocFunction::tryExecute(const List &args)
   String str = args[0].toString();
   DOM::DOMString s = str.value().string();
 
-  switch(_id) {
+  switch(id) {
   case CreateElement:
     result = getDOMNode(doc.createElement(s));
     break;
@@ -670,7 +670,7 @@ KJSO DOMElement::tryGet(const UString &p) const
 
 
 DOMElementFunction::DOMElementFunction(DOM::Element e, int i)
-  : element(e), _id(i)
+  : element(e), id(i)
 {
 }
 
@@ -678,7 +678,7 @@ Completion DOMElementFunction::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch(_id) {
+  switch(id) {
     case GetAttribute:
       result = String(element.getAttribute(args[0].toString().value().string()));
       break;
@@ -746,7 +746,7 @@ KJSO DOMDOMImplementation::tryGet(const UString &p) const
 }
 
 DOMDOMImplementationFunction::DOMDOMImplementationFunction(DOM::DOMImplementation impl, int i)
-  : implementation(impl), _id(i)
+  : implementation(impl), id(i)
 {
 }
 
@@ -754,7 +754,7 @@ Completion DOMDOMImplementationFunction::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch(_id) {
+  switch(id) {
     case HasFeature:
       result = Boolean(implementation.hasFeature(args[0].toString().value().string(),args[1].toString().value().string()));
       break;
@@ -836,7 +836,7 @@ KJSO DOMNamedNodeMap::tryGet(const UString &p) const
 }
 
 DOMNamedNodeMapFunction::DOMNamedNodeMapFunction(DOM::NamedNodeMap m, int i)
-  : map(m), _id(i)
+  : map(m), id(i)
 {
 }
 
@@ -844,7 +844,7 @@ Completion DOMNamedNodeMapFunction::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch(_id) {
+  switch(id) {
     case GetNamedItem:
       result = getDOMNode(map.getNamedItem(args[0].toString().value().string()));
       break;
diff --git a/WebCore/khtml/ecma/kjs_dom.h b/WebCore/khtml/ecma/kjs_dom.h
index ea42e7a..f57057f 100644
--- a/WebCore/khtml/ecma/kjs_dom.h
+++ b/WebCore/khtml/ecma/kjs_dom.h
@@ -31,6 +31,9 @@
 #include "kjs_binding.h"
 #include "kjs_css.h"
 
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#define id id_
+#endif /* APPLE_CHANGES, __OBJC__ */
 namespace KJS {
 
   class DOMNode : public DOMObject {
@@ -58,14 +61,14 @@ namespace KJS {
   class DOMNodeFunc : public DOMFunction {
     friend class DOMNode;
   public:
-    DOMNodeFunc(DOM::Node n, int i) : node(n), _id(i) { }
+    DOMNodeFunc(DOM::Node n, int i) : node(n), id(i) { }
     Completion tryExecute(const List &);
     enum { InsertBefore, ReplaceChild, RemoveChild, AppendChild,
 	   HasChildNodes, CloneNode, AddEventListener, RemoveEventListener,
 	   DispatchEvent };
   private:
     DOM::Node node;
-    int _id;
+    int id;
   };
 
   class DOMNodeList : public DOMObject {
@@ -84,12 +87,12 @@ namespace KJS {
   class DOMNodeListFunc : public DOMFunction {
     friend class DOMNodeList;
   public:
-    DOMNodeListFunc(DOM::NodeList l, int i) : list(l), _id(i) { }
+    DOMNodeListFunc(DOM::NodeList l, int i) : list(l), id(i) { }
     Completion tryExecute(const List &);
     enum { Item };
   private:
     DOM::NodeList list;
-    int _id;
+    int id;
   };
 
   class DOMDocument : public DOMNode {
@@ -112,7 +115,7 @@ namespace KJS {
 	   CreateRange, CreateNodeIterator, CreateTreeWalker, CreateEvent, GetOverrideStyle };
   private:
     DOM::Document doc;
-    int _id;
+    int id;
   };
 
   class DOMAttr : public DOMNode {
@@ -144,7 +147,7 @@ namespace KJS {
            Normalize };
   private:
     DOM::Element element;
-    int _id;
+    int id;
   };
 
   class DOMDOMImplementation : public DOMObject {
@@ -167,7 +170,7 @@ namespace KJS {
     enum { HasFeature, CreateDocumentType, CreateDocument, CreateCSSStyleSheet };
   private:
     DOM::DOMImplementation implementation;
-    int _id;
+    int id;
   };
 
   class DOMDocumentType : public DOMNode {
@@ -200,7 +203,7 @@ namespace KJS {
            GetNamedItemNS, SetNamedItemNS, RemoveNamedItemNS };
   private:
     DOM::NamedNodeMap map;
-    int _id;
+    int id;
   };
 
   class DOMProcessingInstruction : public DOMNode {
@@ -258,5 +261,8 @@ namespace KJS {
   KJSO getDOMExceptionPrototype();
 
 }; // namespace
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#undef id
+#endif /* APPLE_CHANGES, __OBJC__ */
 
 #endif
diff --git a/WebCore/khtml/ecma/kjs_window.cpp b/WebCore/khtml/ecma/kjs_window.cpp
index 04d77dd..50ee5b3 100644
--- a/WebCore/khtml/ecma/kjs_window.cpp
+++ b/WebCore/khtml/ecma/kjs_window.cpp
@@ -798,7 +798,6 @@ bool Window::isSafeScript() const
   KHTMLPart *act = (KHTMLPart*)KJS::Global::current().extra();
   if (!act)
       kdDebug(6070) << "Window::isSafeScript: KJS::Global::current().extra() is 0L!" << endl;
-  
   return act && originCheck(m_part->url(), act->url());
 }
 
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index cae01fb..edae300 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -180,7 +180,7 @@ QByteArray HTMLFormElementImpl::formData()
     QCString enc_string = ""; // used for non-multipart data
 
     // find out the QTextcodec to use
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     QString origStr = m_acceptcharset.string();
     QChar space(' ');
     QChar strChars[origStr.length()];
@@ -191,15 +191,11 @@ QByteArray HTMLFormElementImpl::formData()
         else
             strChars[i] = origStr[i];
     QString str(strChars, origStr.length());
-#else
+#else /* APPLE_CHANGES not defined */
     QString str = m_acceptcharset.string();
     QChar space(' ');
-
-    for(unsigned int i=0; i < str.length(); i++)
-        if(str[i].latin1() == ',')
-            str[i] = space;
-#endif
-
+    for(unsigned int i=0; i < str.length(); i++) if(str[i].latin1() == ',') str[i] = space;
+#endif /* APPLE_CHANGES not defined */
     QStringList charsets = QStringList::split(' ', str);
     QTextCodec* codec = 0;
     for ( QStringList::Iterator it = charsets.begin(); it != charsets.end(); ++it )
@@ -225,17 +221,17 @@ QByteArray HTMLFormElementImpl::formData()
     if(!codec)
         codec = QTextCodec::codecForLocale();
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     QString encCharset = codec->name();
     QChar encChars[encCharset.length()];
     for(unsigned int i=0; i < encCharset.length(); i++)
         encChars[i] = encCharset[i].latin1() == ' ' ? QChar('-') : encCharset[i].lower();
     QString m_encCharset(encChars,  encCharset.length());
-#else
+#else /* APPLE_CHANGES not defined */
     m_encCharset = codec->name();
     for(unsigned int i=0; i < m_encCharset.length(); i++)
         m_encCharset[i] = m_encCharset[i].latin1() == ' ' ? QChar('-') : m_encCharset[i].lower();
-#endif
+#endif /* APPLE_CHANGES not defined */
 
     for(HTMLGenericFormElementImpl *current = formElements.first(); current; current = formElements.next())
     {
@@ -1509,18 +1505,14 @@ void HTMLSelectElementImpl::setValue(DOMStringImpl* /*value*/)
 
 QString HTMLSelectElementImpl::state( )
 {
+#ifndef APPLE_CHANGES
+    QString state;
+#endif /* APPLE_CHANGES not defined */
     QArray<HTMLGenericFormElementImpl*> items = listItems();
 
     int l = items.count();
 
-#ifndef _KWQ_
-    QString state;
-
-    state.fill('.', l);
-    for(int i = 0; i < l; i++)
-        if(items[i]->id() == ID_OPTION && static_cast<HTMLOptionElementImpl*>(items[i])->selected())
-            state[i] = 'X';
-#else
+#ifdef APPLE_CHANGES
     QChar stateChars[l];
     
     for(int i = 0; i < l; i++)
@@ -1529,7 +1521,12 @@ QString HTMLSelectElementImpl::state( )
         else
             stateChars[i] = '.';
     QString state(stateChars, l);
-#endif
+#else /* APPLE_CHANGES not defined */
+    state.fill('.', l);
+    for(int i = 0; i < l; i++)
+        if(items[i]->id() == ID_OPTION && static_cast<HTMLOptionElementImpl*>(items[i])->selected())
+            state[i] = 'X';
+#endif /* APPLE_CHANGES not defined */
 
     return state;
 }
@@ -1541,13 +1538,13 @@ void HTMLSelectElementImpl::restoreState(const QString &_state)
     QString state = _state;
     if(!state.isEmpty() && !state.contains('X') && !m_multiple) {
         ASSERT("should not happen in restoreState!");
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
         // Invalid access to string's internal buffer.  Should never get here
         // anyway.
         //state[0] = 'X';
-#else
+#else /* APPLE_CHANGES not defined */
         state[0] = 'X';
-#endif
+#endif /* APPLE_CHANGES not defined */
     }
 
     QArray<HTMLGenericFormElementImpl*> items = listItems();
diff --git a/WebCore/khtml/html/html_headimpl.cpp b/WebCore/khtml/html/html_headimpl.cpp
index 599d2fc..925d285 100644
--- a/WebCore/khtml/html/html_headimpl.cpp
+++ b/WebCore/khtml/html/html_headimpl.cpp
@@ -148,9 +148,14 @@ void HTMLLinkElementImpl::attach()
 
 void HTMLLinkElementImpl::detach()
 {
+#ifdef APPLE_CHANGES
     // RJW:  Why is this done here?
     //if ( sheet() )
     //    getDocument()->createSelector();
+#else /* APPLE_CHANGES not defined */
+    if ( sheet() )
+        getDocument()->createSelector();
+#endif /* APPLE_CHANGES not defined */
 
     HTMLElementImpl::detach();
 }
@@ -432,9 +437,12 @@ void HTMLStyleElementImpl::attach()
 
 void HTMLStyleElementImpl::detach()
 {
+#ifdef APPLE_CHANGES
     // RJW:  Why is this done?
-    //if (m_sheet)
-    //    getDocument()->createSelector();
+    //if (m_sheet) getDocument()->createSelector();
+#else /* APPLE_CHANGES not defined */
+    if (m_sheet) getDocument()->createSelector();
+#endif /* APPLE_CHANGES not defined */
     HTMLElementImpl::detach();
 }
 
@@ -467,8 +475,14 @@ void HTMLTitleElementImpl::setTitle()
     s.compose();
     s = KStringHandler::csqueeze( s.visual(), 128 );
 
+#ifdef APPLE_CHANGES
     // FIXME: need to uncomment this eventually
     //HTMLDocumentImpl *d = static_cast<HTMLDocumentImpl *>(ownerDocument());
     //if ( !d->view()->part()->parentPart() )
     //    emit d->view()->part()->setWindowCaption( s.visual() );
+#else /* APPLE_CHANGES not defined */
+    HTMLDocumentImpl *d = static_cast<HTMLDocumentImpl *>(ownerDocument());
+    if ( !d->view()->part()->parentPart() )
+        emit d->view()->part()->setWindowCaption( s.visual() );
+#endif /* APPLE_CHANGES not defined */
 }
diff --git a/WebCore/khtml/html/html_objectimpl.cpp b/WebCore/khtml/html/html_objectimpl.cpp
index 37becc9..7b04db8 100644
--- a/WebCore/khtml/html/html_objectimpl.cpp
+++ b/WebCore/khtml/html/html_objectimpl.cpp
@@ -188,13 +188,13 @@ void HTMLEmbedElementImpl::parseAttribute(AttrImpl *attr)
   QString val = QConstString( stringImpl->s, stringImpl->l ).string();
 
   // export parameter
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     // Need to make a deep copy here or "+" operator will attempt to modify
     // QConstString attribute name
   QString attrStr = attr->name().string().copy() + "=\"" + val + "\"";
-#else
+#else /* APPLE_CHANGES not defined */
   QString attrStr = attr->name().string() + "=\"" + val + "\"";
-#endif
+#endif /* APPLE_CHANGES not defined */
   param.append( attrStr );
   int pos;
   switch ( attr->attrId )
@@ -207,11 +207,11 @@ void HTMLEmbedElementImpl::parseAttribute(AttrImpl *attr)
         break;
      case ATTR_CODE:
      case ATTR_SRC:
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
          url = khtml::parseURL(attr->val()).string().copy();
-#else
+#else /* APPLE_CHANGES not defined */
          url = khtml::parseURL(attr->val()).string();
-#endif
+#endif /* APPLE_CHANGES not defined */
          break;
      case ATTR_WIDTH:
         addCSSLength( CSS_PROP_WIDTH, attr->value() );
diff --git a/WebCore/khtml/html/html_tableimpl.cpp b/WebCore/khtml/html/html_tableimpl.cpp
index 1873ef2..2e91853 100644
--- a/WebCore/khtml/html/html_tableimpl.cpp
+++ b/WebCore/khtml/html/html_tableimpl.cpp
@@ -313,18 +313,15 @@ void HTMLTableElementImpl::parseAttribute(AttrImpl *attr)
     {
         if (!attr->value().isEmpty()) {
             HTMLDocumentImpl *doc = static_cast<HTMLDocumentImpl *>(ownerDocument());
-                        
-#ifdef _KWQ_            
+#ifdef APPLE_CHANGES
             // our c++ implementation likes this better
             DOMString d(khtml::parseURL(attr->value()));
             QString url = d.string();
-#else            
+#else /* APPLE_CHANGES not defined */
             QString url = khtml::parseURL( attr->value() ).string();
-#endif
-            
+#endif /* APPLE_CHANGES not defined */
             if ( doc->view() )
                 url = doc->view()->part()->completeURL( url ).url();
-                
             addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, "url('"+url+"')" );
         }
         else
@@ -437,17 +434,15 @@ void HTMLTablePartElementImpl::parseAttribute(AttrImpl *attr)
     {
         if (attr->val()) {
             HTMLDocumentImpl *doc = static_cast<HTMLDocumentImpl *>(ownerDocument());
-
-#ifdef _KWQ_            
+#ifdef APPLE_CHANGES
             // our c++ implementation likes this better
             DOMString d(khtml::parseURL(attr->value()));
             QString url = d.string();
-#else            
+#else /* APPLE_CHANGES not defined */
             QString url = khtml::parseURL( attr->value() ).string();
-#endif
+#endif /* APPLE_CHANGES not defined */
             if ( doc->view() )
                 url = doc->view()->part()->completeURL( url ).url();
-                
             addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, "url('"+url+"')" );
         }
         else
diff --git a/WebCore/khtml/html/htmlparser.cpp b/WebCore/khtml/html/htmlparser.cpp
index d59106d..47342aa 100644
--- a/WebCore/khtml/html/htmlparser.cpp
+++ b/WebCore/khtml/html/htmlparser.cpp
@@ -72,13 +72,13 @@ public:
                    HTMLStackElem * _next
         )
         :
-        _id(_id),
+        id(_id),
         level(_level),
         node(_node),
         next(_next)
         { }
 
-    int       _id;
+    int       id;
     int       level;
     NodeImpl *node;
     HTMLStackElem *next;
@@ -185,39 +185,39 @@ void KHTMLParser::reset()
 
 void KHTMLParser::parseToken(Token *t)
 {
-    if (t->_id > 2*ID_CLOSE_TAG)
+    if (t->id > 2*ID_CLOSE_TAG)
     {
-      kdDebug( 6035 ) << "Unknown tag!! tagID = " << t->_id << endl;
+      kdDebug( 6035 ) << "Unknown tag!! tagID = " << t->id << endl;
       return;
     }
     if(discard_until) {
-        if(t->_id == discard_until)
+        if(t->id == discard_until)
             discard_until = 0;
 
         // do not skip </iframe>
-        if ( discard_until || current->id() + ID_CLOSE_TAG != t->_id )
+        if ( discard_until || current->id() + ID_CLOSE_TAG != t->id )
             return;
     }
 
 #ifdef PARSER_DEBUG
-    kdDebug( 6035 ) << "\n\n==> parser: processing token " << getTagName(t->_id).string() << "(" << t->_id << ")"
+    kdDebug( 6035 ) << "\n\n==> parser: processing token " << getTagName(t->id).string() << "(" << t->id << ")"
                     << " current = " << getTagName(current->id()).string() << "(" << current->id() << ")" << endl;
     kdDebug(6035) << "inline=" << _inline << " inBody=" << inBody << " noRealBody=" << noRealBody << " haveFrameSet=" << haveFrameSet << endl;
 #endif
 
     // holy shit. apparently some sites use </br> instead of <br>
     // be compatible with IE and NS
-    if(t->_id == ID_BR+ID_CLOSE_TAG && document->document()->parseMode() != DocumentImpl::Strict)
-        t->_id -= ID_CLOSE_TAG;
+    if(t->id == ID_BR+ID_CLOSE_TAG && document->document()->parseMode() != DocumentImpl::Strict)
+        t->id -= ID_CLOSE_TAG;
 
-    if(t->_id > ID_CLOSE_TAG)
+    if(t->id > ID_CLOSE_TAG)
     {
         processCloseTag(t);
         return;
     }
 
     // ignore spaces, if we're not inside a paragraph or other inline code
-    if( t->_id == ID_TEXT ) {
+    if( t->id == ID_TEXT ) {
 #ifdef PARSER_DEBUG
         if(t->text)
             kdDebug(6035) << "length="<< t->text->l << " text='" << QConstString(t->text->s, t->text->l).string() << "'" << endl;
@@ -239,12 +239,12 @@ void KHTMLParser::parseToken(Token *t)
 
         // take care of optional close tags
         if(endTag[e->id()] == DOM::OPTIONAL)
-            popBlock(t->_id);
+            popBlock(t->id);
     }
 
     // if this tag is forbidden inside the current context, pop
     // blocks until we are allowed to add it...
-    while(forbiddenTag[t->_id]) popOneBlock();
+    while(forbiddenTag[t->id]) popOneBlock();
 
     if ( !insertNode(n) ) {
         // we couldn't insert the node...
@@ -271,7 +271,7 @@ void KHTMLParser::parseToken(Token *t)
 
 bool KHTMLParser::insertNode(NodeImpl *n)
 {
-    int _id = n->id();
+    int id = n->id();
 
     // let's be stupid and just try to insert it.
     // this should work if the document is wellformed
@@ -284,9 +284,9 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         kdDebug( 6035 ) << "added " << n->nodeName().string() << " to " << tmp->nodeName().string() << ", new current=" << newNode->nodeName().string() << endl;
 #endif
         // don't push elements without end tag on the stack
-        if(tagPriority[_id] != 0 && !flat)
+        if(tagPriority[id] != 0 && !flat)
         {
-            pushBlock(_id, tagPriority[_id]);
+            pushBlock(id, tagPriority[id]);
             current = newNode;
 #if SPEED_DEBUG < 2
             if(!n->attached() && HTMLWidget )  n->attach();
@@ -303,7 +303,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         }
 
 #if SPEED_DEBUG < 1
-        if(tagPriority[_id] == 0 && n->renderer())
+        if(tagPriority[id] == 0 && n->renderer())
             n->renderer()->calcMinMaxWidth();
 #endif
         return true;
@@ -316,7 +316,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         bool handled = false;
 
         // switch according to the element to insert
-        switch(_id)
+        switch(id)
         {
         case ID_COMMENT:
             break;
@@ -351,7 +351,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
             if ( head ) {
                 DOM::NodeImpl *newNode = head->addChild(n);
                 if ( newNode ) {
-                    pushBlock(_id, tagPriority[_id]);
+                    pushBlock(id, tagPriority[id]);
                     current = newNode;
 #if SPEED_DEBUG < 2
                     if(!n->attached() && HTMLWidget)
@@ -455,7 +455,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         switch(current->id())
         {
         case ID_HTML:
-            switch(_id)
+            switch(id)
             {
             case ID_SCRIPT:
             case ID_STYLE:
@@ -493,7 +493,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
             break;
         case ID_HEAD:
             // we can get here only if the element is not allowed in head.
-            if (_id == ID_HTML)
+            if (id == ID_HTML)
                 return false;
             else {
                 // This means the body starts here...
@@ -508,7 +508,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         case ID_BODY:
             break;
         case ID__KONQBLOCK:
-            switch( _id ) {
+            switch( id ) {
             case ID_THEAD:
             case ID_TFOOT:
             case ID_TBODY:
@@ -520,7 +520,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
                 // and go ahead!
                 popBlock( ID__KONQBLOCK );
                 haveKonqBlock = false;
-                handled = checkChild( current->id(), _id );
+                handled = checkChild( current->id(), id );
                 break;
             default:
                 break;
@@ -531,7 +531,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         case ID_TFOOT:
         case ID_TBODY:
         case ID_TR:
-            switch(_id)
+            switch(id)
             {
             case ID_TABLE:
                 popBlock(ID_TABLE); // end the table
@@ -558,7 +558,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
                    ( parent->id() == ID_THEAD ||
                      parent->id() == ID_TBODY ||
                      parent->id() == ID_TFOOT ) && parentparent->id() == ID_TABLE ) ||
-                   ( !checkChild( ID_TR, _id ) && ( node->id() == ID_THEAD || node->id() == ID_TBODY || node->id() == ID_TFOOT ) &&
+                   ( !checkChild( ID_TR, id ) && ( node->id() == ID_THEAD || node->id() == ID_TBODY || node->id() == ID_TFOOT ) &&
                      parent->id() == ID_TABLE ) )
                 {
                     node = ( node->id() == ID_TR ) ? parentparent : parent;
@@ -594,7 +594,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
             } // end switch
             break;
         case ID_OBJECT:
-            discard_until = _id + ID_CLOSE_TAG;
+            discard_until = id + ID_CLOSE_TAG;
             return false;
         case ID_UL:
         case ID_OL:
@@ -631,12 +631,12 @@ bool KHTMLParser::insertNode(NodeImpl *n)
             }
             break;
         case ID_OPTION:
-            if (_id == ID_OPTGROUP)
+            if (id == ID_OPTGROUP)
             {
                 popBlock(ID_OPTION);
                 handled = true;
             }
-            else if(_id == ID_SELECT)
+            else if(id == ID_SELECT)
             {
                 // IE treats a nested select as </select>. Let's do the same
                 popBlock( ID_SELECT );
@@ -689,7 +689,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
 {
     NodeImpl *n = 0;
 
-    switch(t->_id)
+    switch(t->id)
     {
     case ID_HTML:
         n = new HTMLHtmlElementImpl(document);
@@ -800,12 +800,12 @@ NodeImpl *KHTMLParser::getElement(Token* t)
         n = new HTMLDListElementImpl(document);
         break;
     case ID_DD:
-        n = new HTMLGenericElementImpl(document, t->_id);
+        n = new HTMLGenericElementImpl(document, t->id);
         popBlock(ID_DT);
         popBlock(ID_DD);
         break;
     case ID_DT:
-        n = new HTMLGenericElementImpl(document, t->_id);
+        n = new HTMLGenericElementImpl(document, t->id);
         popBlock(ID_DD);
         popBlock(ID_DT);
         break;
@@ -850,7 +850,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
     case ID_H4:
     case ID_H5:
     case ID_H6:
-        n = new HTMLHeadingElementImpl(document, t->_id);
+        n = new HTMLHeadingElementImpl(document, t->id);
         break;
     case ID_HR:
         n = new HTMLHRElementImpl(document);
@@ -874,7 +874,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
 // ins/del
     case ID_DEL:
     case ID_INS:
-        n = new HTMLModElementImpl(document, t->_id);
+        n = new HTMLModElementImpl(document, t->id);
         break;
 
 // anchor
@@ -920,7 +920,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
         break;
     case ID_COLGROUP:
     case ID_COL:
-        n = new HTMLTableColElementImpl(document, t->_id);
+        n = new HTMLTableColElementImpl(document, t->id);
         break;
     case ID_TR:
         popBlock(ID_TR);
@@ -930,7 +930,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
     case ID_TH:
         popBlock(ID_TH);
         popBlock(ID_TD);
-        n = new HTMLTableCellElementImpl(document, t->_id);
+        n = new HTMLTableCellElementImpl(document, t->id);
         break;
     case ID_TBODY:
     case ID_THEAD:
@@ -938,7 +938,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
         popBlock( ID_THEAD );
         popBlock( ID_TBODY );
         popBlock( ID_TFOOT );
-        n = new HTMLTableSectionElementImpl(document, t->_id);
+        n = new HTMLTableSectionElementImpl(document, t->id);
         break;
 
 // inline elements
@@ -955,7 +955,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
     case ID_ADDRESS:
     case ID_CENTER:
     case ID_LISTING:
-        n = new HTMLGenericElementImpl(document, t->_id);
+        n = new HTMLGenericElementImpl(document, t->id);
         break;
 // inline
         // %fontstyle
@@ -984,7 +984,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
     case ID_SUB:
     case ID_SUP:
     case ID_SPAN:
-        n = new HTMLGenericElementImpl(document, t->_id);
+        n = new HTMLGenericElementImpl(document, t->id);
         break;
 
     case ID_BDO:
@@ -1017,7 +1017,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
 #endif
         break;
     default:
-        kdDebug( 6035 ) << "Unknown tag " << t->_id << "!" << endl;
+        kdDebug( 6035 ) << "Unknown tag " << t->id << "!" << endl;
     }
     return n;
 }
@@ -1025,7 +1025,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
 void KHTMLParser::processCloseTag(Token *t)
 {
     // support for really broken html. Can't believe I'm supporting such crap (lars)
-    switch(t->_id)
+    switch(t->id)
     {
     case ID_HTML+ID_CLOSE_TAG:
     case ID_BODY+ID_CLOSE_TAG:
@@ -1064,7 +1064,7 @@ void KHTMLParser::processCloseTag(Token *t)
         child = child->nextSibling();
     }
 #endif
-    popBlock(t->_id-ID_CLOSE_TAG);
+    popBlock(t->id-ID_CLOSE_TAG);
 #ifdef PARSER_DEBUG
     kdDebug( 6035 ) << "closeTag --> current = " << current->nodeName().string() << endl;
 #endif
@@ -1087,13 +1087,13 @@ void KHTMLParser::popBlock( int _id )
 #ifdef PARSER_DEBUG
     kdDebug( 6035 ) << "popBlock(" << getTagName(_id).string() << ")" << endl;
     while(Elem) {
-        kdDebug( 6035) << "   > " << getTagName(Elem->_id).string() << endl;
+        kdDebug( 6035) << "   > " << getTagName(Elem->id).string() << endl;
         Elem = Elem->next;
     }
     Elem = blockStack;
 #endif
 
-    while( Elem && (Elem->_id != _id))
+    while( Elem && (Elem->id != _id))
     {
         if (maxLevel < Elem->level)
         {
@@ -1108,7 +1108,7 @@ void KHTMLParser::popBlock( int _id )
 
     while (Elem)
     {
-        if (Elem->_id == _id)
+        if (Elem->id == _id)
         {
             popOneBlock();
             Elem = 0;
@@ -1129,7 +1129,7 @@ void KHTMLParser::popOneBlock()
 #ifndef PARSER_DEBUG
     if(!Elem) return;
 #else
-    kdDebug( 6035 ) << "popping block: " << getTagName(Elem->_id).string() << "(" << Elem->_id << ")" << endl;
+    kdDebug( 6035 ) << "popping block: " << getTagName(Elem->id).string() << "(" << Elem->id << ")" << endl;
 #endif
 
 #if SPEED_DEBUG < 1
@@ -1137,7 +1137,7 @@ void KHTMLParser::popOneBlock()
         if(current->renderer()) current->renderer()->close();
 #endif
 
-    removeForbidden(Elem->_id, forbiddenTag);
+    removeForbidden(Elem->id, forbiddenTag);
 
     blockStack = Elem->next;
     // we only set inline to false, if the element we close is a block level element.
diff --git a/WebCore/khtml/html/htmltokenizer.cpp b/WebCore/khtml/html/htmltokenizer.cpp
index 694c83c..cb93849 100644
--- a/WebCore/khtml/html/htmltokenizer.cpp
+++ b/WebCore/khtml/html/htmltokenizer.cpp
@@ -296,9 +296,9 @@ void HTMLTokenizer::parseSpecial(DOMStringIt &src, bool begin)
                 scriptHandler();
             else {
                 processListing(DOMStringIt(scriptCode, scriptCodeSize));
-                if ( style )         { currToken._id = ID_STYLE + ID_CLOSE_TAG; }
-                else if ( textarea ) { currToken._id = ID_TEXTAREA + ID_CLOSE_TAG; }
-                else if ( listing )  { currToken._id = ID_LISTING + ID_CLOSE_TAG; }
+                if ( style )         { currToken.id = ID_STYLE + ID_CLOSE_TAG; }
+                else if ( textarea ) { currToken.id = ID_TEXTAREA + ID_CLOSE_TAG; }
+                else if ( listing )  { currToken.id = ID_LISTING + ID_CLOSE_TAG; }
                 processToken();
                 style = script = style = textarea = listing = false;
                 scriptCodeSize = scriptCodeResync = 0;
@@ -354,7 +354,7 @@ void HTMLTokenizer::scriptHandler()
         doScriptExec = true;
     }
     processListing(DOMStringIt(scriptCode, scriptCodeSize));
-    currToken._id = ID_SCRIPT + ID_CLOSE_TAG;
+    currToken.id = ID_SCRIPT + ID_CLOSE_TAG;
     processToken();
 
     QString prependingSrc;
@@ -416,10 +416,10 @@ void HTMLTokenizer::parseComment(DOMStringIt &src)
                 checkScriptBuffer();
                 scriptCode[ scriptCodeSize ] = 0;
                 scriptCode[ scriptCodeSize + 1 ] = 0;
-                currToken._id = ID_COMMENT;
+                currToken.id = ID_COMMENT;
                 processListing(DOMStringIt(scriptCode, scriptCodeSize - 2));
                 processToken();
-                currToken._id = ID_COMMENT + ID_CLOSE_TAG;
+                currToken.id = ID_COMMENT + ID_CLOSE_TAG;
                 processToken();
 #endif
                 scriptCodeSize = 0;
@@ -743,7 +743,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
                     QCString tmp(ptr, len+1);
                     kdDebug( 6036 ) << "found tag id=" << tagID << ": " << tmp.data() << endl;
 #endif
-                    currToken._id = beginTag ? tagID : tagID + ID_CLOSE_TAG;
+                    currToken.id = beginTag ? tagID : tagID + ID_CLOSE_TAG;
                     dest = buffer;
                 }
                 tag = SearchAttribute;
@@ -1000,10 +1000,10 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
             tquote = NoQuote;
             ++src;
 
-            if ( !currToken._id ) //stop if tag is unknown
+            if ( !currToken.id ) //stop if tag is unknown
                 return;
 
-            uint tagID = currToken._id;
+            uint tagID = currToken.id;
 #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 0
             kdDebug( 6036 ) << "appending Tag: " << tagID << endl;
 #endif
@@ -1444,8 +1444,8 @@ void HTMLTokenizer::processToken()
     if ( dest > buffer )
     {
 #ifdef TOKEN_DEBUG
-        if(currToken._id && currToken._id != ID_COMMENT) {
-            qDebug( "unexpected token id: %d, str: *%s*", currToken._id,QConstString( buffer,dest-buffer ).string().latin1() );
+        if(currToken.id && currToken.id != ID_COMMENT) {
+            qDebug( "unexpected token id: %d, str: *%s*", currToken.id,QConstString( buffer,dest-buffer ).string().latin1() );
             assert(0);
         }
 
@@ -1461,10 +1461,10 @@ void HTMLTokenizer::processToken()
             currToken.text = new DOMStringImpl( buffer, dest - buffer );
             currToken.text->ref();
         }
-        if (currToken._id != ID_COMMENT)
-            currToken._id = ID_TEXT;
+        if (currToken.id != ID_COMMENT)
+            currToken.id = ID_TEXT;
     }
-    else if(!currToken._id) {
+    else if(!currToken.id) {
         currToken.reset();
         return;
     }
@@ -1472,12 +1472,12 @@ void HTMLTokenizer::processToken()
     dest = buffer;
 
 #ifdef TOKEN_DEBUG
-    QString name = getTagName(currToken._id).string();
+    QString name = getTagName(currToken.id).string();
     QString text;
     if(currToken.text)
         text = QConstString(currToken.text->s, currToken.text->l).string();
 
-    kdDebug( 6036 ) << "Token --> " << name << "   id = " << currToken._id << endl;
+    kdDebug( 6036 ) << "Token --> " << name << "   id = " << currToken.id << endl;
     if(!text.isNull())
         kdDebug( 6036 ) << "text: \"" << text << "\"" << endl;
     int l = currToken.attrs ? currToken.attrs->length() : 0;
diff --git a/WebCore/khtml/html/htmltokenizer.h b/WebCore/khtml/html/htmltokenizer.h
index 9fdfe40..62a5e37 100644
--- a/WebCore/khtml/html/htmltokenizer.h
+++ b/WebCore/khtml/html/htmltokenizer.h
@@ -54,6 +54,9 @@ class HTMLTokenizer;
 #include "misc/htmltags.h"
 #include "xml/dom_stringimpl.h"
 
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#define id id_
+#endif /* APPLE_CHANGES, __OBJC__ */
 class KHTMLParser;
 class KHTMLView;
 
@@ -76,7 +79,7 @@ namespace khtml {
     {
     public:
         Token() {
-            _id = 0;
+            id = 0;
             complexText = false;
             attrs = 0;
             text = 0;
@@ -100,7 +103,7 @@ namespace khtml {
                 attrs->deref();
                 attrs = 0;
             }
-            _id = 0;
+            id = 0;
             complexText = false;
             if(text) {
                 text->deref();
@@ -108,7 +111,7 @@ namespace khtml {
             }
         }
         DOM::NamedAttrMapImpl* attrs;
-        ushort _id;
+        ushort id;
         DOMStringImpl* text;
         bool complexText;
     };
@@ -133,8 +136,12 @@ public:
     virtual void setOnHold(bool /*_onHold*/) {}
 
 signals:
+#ifdef APPLE_CHANGES
     // temporary implementation here to get test to link
     void finishedParsing() {};
+#else /* APPLE_CHANGES not defined */
+    void finishedParsing();
+#endif /* APPLE_CHANGES not defined */
 
 };
 
@@ -357,6 +364,9 @@ protected:
 
     KHTMLView *view;
 };
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#undef id
+#endif /* APPLE_CHANGES, __OBJC__ */
 
 #endif // HTMLTOKENIZER
 
diff --git a/WebCore/khtml/java/kjavaprocess.h b/WebCore/khtml/java/kjavaprocess.h
index fc113ff..7b18ec2 100644
--- a/WebCore/khtml/java/kjavaprocess.h
+++ b/WebCore/khtml/java/kjavaprocess.h
@@ -26,7 +26,9 @@
 
 #include <kprocess.h>
 #include <qcstring.h>
+#ifdef APPLE_CHANGES
 #include <qlist.h>
+#endif /* APPLE_CHANGES */
 
 /**
  * @short A class for invoking a Java VM
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index a94704d..e7c26a0 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -21,10 +21,9 @@
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-#ifndef ORIGINAL_KHTMLPART_HEADER
+#ifdef APPLE_CHANGES
 #include "../../kwq/KWQKHTMLPart.h"
-#else 
-
+#else /* APPLE_CHANGES not defined */
 #ifndef __khtml_part_h__
 #define __khtml_part_h__
 
@@ -1049,5 +1048,4 @@ private:
 
 
 #endif
-
-#endif
+#endif /* APPLE_CHANGES not defined */
diff --git a/WebCore/khtml/khtmlview.cpp b/WebCore/khtml/khtmlview.cpp
index 4fcfdb7..350dbb9 100644
--- a/WebCore/khtml/khtmlview.cpp
+++ b/WebCore/khtml/khtmlview.cpp
@@ -71,12 +71,20 @@ public:
     {
         underMouse = 0;
         reset();
+#ifndef APPLE_CHANGES
+        tp=0;
+        paintBuffer=0;
+#endif /* APPLE_CHANGES not defined */
         formCompletions=0;
         prevScrollbarVisible = true;
     }
     ~KHTMLViewPrivate()
     {
         delete formCompletions;
+#ifndef APPLE_CHANGES
+        delete tp; tp = 0;
+        delete paintBuffer; paintBuffer =0;
+#endif /* APPLE_CHANGES not defined */
         if (underMouse)
 	    underMouse->deref();
     }
@@ -106,8 +114,12 @@ public:
 	isDoubleClick = false;
     }
 
+#ifdef APPLE_CHANGES
     // The paintBuffer ivar is obsolete, 
     // and should probably be removed at some point
+#else /* APPLE_CHANGES not defined */
+    QPainter *tp;
+#endif /* APPLE_CHANGES not defined */
     QPixmap  *paintBuffer;
     NodeImpl *underMouse;
 
@@ -143,10 +155,9 @@ public:
         m_viewprivate = vp;
     };
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     virtual ~KHTMLToolTip() {}
-#endif
-
+#endif /* APPLE_CHANGES */
 protected:
     virtual void maybeTip(const QPoint &);
 
@@ -200,6 +211,16 @@ KHTMLView::KHTMLView( KHTMLPart *part, QWidget *parent, const char *name)
 
 KHTMLView::~KHTMLView()
 {
+#ifndef APPLE_CHANGES
+    if (m_part)
+    {
+        //WABA: Is this Ok? Do I need to deref it as well?
+        //Does this need to be done somewhere else?
+        DOM::DocumentImpl *doc = m_part->xmlDocImpl();
+        if (doc)
+            doc->detach();
+    }
+#endif /* APPLE_CHANGES not defined */
     lstViews->removeRef( this );
     if(lstViews->isEmpty())
     {
@@ -217,6 +238,11 @@ void KHTMLView::init()
     lstViews->setAutoDelete( FALSE );
     lstViews->append( this );
 
+#ifndef APPLE_CHANGES
+    if(!d->paintBuffer) d->paintBuffer = new QPixmap(PAINT_BUFFER_HEIGHT, PAINT_BUFFER_HEIGHT);
+   if(!d->tp) d->tp = new QPainter();
+#endif /* APPLE_CHANGES not defined */
+
     setFocusPolicy(QWidget::StrongFocus);
     viewport()->setFocusPolicy( QWidget::WheelFocus );
     viewport()->setFocusProxy(this);
@@ -277,13 +303,12 @@ void KHTMLView::resizeEvent (QResizeEvent* e)
     KApplication::sendPostedEvents(viewport(), QEvent::Paint);
 }
 
-#ifdef KWQ_RENDER_TREE_DEBUG
+#ifdef APPLE_RENDER_TREE_DEBUG
 static void printLevel(int level){
     while (level--)
         printf ("    ");
 }
 
-
 static void printRenderTree(RenderObject *node, int level)
 {
     printLevel (level);
@@ -294,9 +319,8 @@ static void printRenderTree(RenderObject *node, int level)
         child = child->nextSibling();
     }
 }
-#endif
-
 
+#endif /* APPLE_RENDER_TREE_DEBUG */
 void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
 {
     if(!m_part->xmlDocImpl()) {
@@ -304,6 +328,7 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
         return;
     }
 
+#ifdef APPLE_CHANGES
     // FIXME!
     RenderObject *ro;
     DOM::DocumentImpl *doc;
@@ -312,19 +337,45 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
     if (doc){
         ro = doc->renderer();
         if (ro){
-#ifdef KWQ_RENDER_TREE_DEBUG
+#ifdef APPLE_RENDER_TREE_DEBUG
                 printRenderTree (ro, 0);
-#endif
+#endif /* APPLE_RENDER_TREE_DEBUG */
             ro->print(p, ex, ey, ew, eh, 0, 0);
         }
     }
+#else /* APPLE_CHANGES not defined */
+    //kdDebug( 6000 ) << "drawContents x=" << ex << ",y=" << ey << ",w=" << ew << ",h=" << eh << endl;
+
+    if ( d->paintBuffer->width() < visibleWidth() )
+        d->paintBuffer->resize(visibleWidth(),PAINT_BUFFER_HEIGHT);
+
+    int py=0;
+    while (py < eh) {
+        int ph = eh-py < PAINT_BUFFER_HEIGHT ? eh-py : PAINT_BUFFER_HEIGHT;
+        d->tp->begin(d->paintBuffer);
+        d->tp->translate(-ex, -ey-py);
+        d->tp->fillRect(ex, ey+py, ew, ph, palette().normal().brush(QColorGroup::Base));
+        m_part->xmlDocImpl()->renderer()->print(d->tp, ex, ey+py, ew, ph, 0, 0);
+#ifdef BOX_DEBUG
+	if (m_part->xmlDocImpl()->focusNode())
+	{
+	    d->tp->setBrush(Qt::NoBrush);
+	    d->tp->drawRect(m_part->xmlDocImpl()->focusNode()->getRect());
+	}
+#endif
+        d->tp->end();
+
+        p->drawPixmap(ex, ey+py, *d->paintBuffer, 0, 0, ew, ph);
+        py += PAINT_BUFFER_HEIGHT;
+    }
+#endif /* APPLE_CHANGES not defined */
 
     khtml::DrawContentsEvent event( p, ex, ey, ew, eh );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
+#endif /* APPLE_CHANGES not defined */
 }
 
 void KHTMLView::layout(bool)
@@ -335,28 +386,32 @@ void KHTMLView::layout(bool)
 
         khtml::RenderRoot* root = static_cast<khtml::RenderRoot *>(document->renderer());
 
+#ifdef APPLE_CHANGES
         if (root != 0){
-            if (document->isHTMLDocument()) {
-                NodeImpl *body = static_cast<HTMLDocumentImpl*>(document)->body();
-                if(body && body->renderer() && body->id() == ID_FRAMESET) {
-                    QScrollView::setVScrollBarMode(AlwaysOff);
-                    QScrollView::setHScrollBarMode(AlwaysOff);
-                    _width = visibleWidth();
-                    body->renderer()->setLayouted(false);
-                    body->renderer()->layout();
-                    root->layout();
-                    return;
-                }
+#endif /* APPLE_CHANGES */
+        if (document->isHTMLDocument()) {
+            NodeImpl *body = static_cast<HTMLDocumentImpl*>(document)->body();
+            if(body && body->renderer() && body->id() == ID_FRAMESET) {
+                QScrollView::setVScrollBarMode(AlwaysOff);
+                QScrollView::setHScrollBarMode(AlwaysOff);
+                _width = visibleWidth();
+                body->renderer()->setLayouted(false);
+                body->renderer()->layout();
+                root->layout();
+                return;
             }
-        
-            _height = visibleHeight();
-            _width = visibleWidth();
-        
-            //QTime qt;
-            //qt.start();
+        }
+#ifdef APPLE_CHANGES
+        }
+#endif /* APPLE_CHANGES */
+
+        _height = visibleHeight();
+        _width = visibleWidth();
+
+        //QTime qt;
+        //qt.start();
             root->layout();
             //kdDebug( 6000 ) << "TIME: layout() dt=" << qt.elapsed() << endl;
-        }
     } else {
         _width = visibleWidth();
     }
@@ -406,11 +461,11 @@ void KHTMLView::viewportMousePressEvent( QMouseEvent *_mouse )
 
     khtml::MousePressEvent event( _mouse, xm, ym, mev.url, mev.innerNode );
     event.setNodePos( mev.nodeAbsX, mev.nodeAbsY );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
+#endif /* APPLE_CHANGES not defined */
 
     emit m_part->nodeActivated(mev.innerNode);
 }
@@ -448,12 +503,11 @@ void KHTMLView::viewportMouseDoubleClickEvent( QMouseEvent *_mouse )
 
     khtml::MouseDoubleClickEvent event( _mouse, xm, ym, mev.url, mev.innerNode );
     event.setNodePos( mev.nodeAbsX, mev.nodeAbsY );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
-
+#endif /* APPLE_CHANGES not defined */
 
     // ###
     //if ( url.length() )
@@ -543,12 +597,11 @@ void KHTMLView::viewportMouseMoveEvent( QMouseEvent * _mouse )
 
     khtml::MouseMoveEvent event( _mouse, xm, ym, mev.url, mev.innerNode );
     event.setNodePos( mev.nodeAbsX, mev.nodeAbsY );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
-
+#endif /* APPLE_CHANGES not defined */
 }
 
 void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse )
@@ -576,12 +629,11 @@ void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse )
 
     khtml::MouseReleaseEvent event( _mouse, xm, ym, mev.url, mev.innerNode );
     event.setNodePos( mev.nodeAbsX, mev.nodeAbsY );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
-
+#endif /* APPLE_CHANGES not defined */
 }
 
 void KHTMLView::keyPressEvent( QKeyEvent *_ke )
@@ -1093,8 +1145,12 @@ void KHTMLView::addFormCompletionItem(const QString &name, const QString &value)
     // dashes or spaces as those are likely credit card numbers or
     // something similar
     bool cc_number(true);
+#ifdef APPLE_CHANGES
     // [kocienda] fixed signed/unsigned int comparison
     for (unsigned int i = 0; i < value.length(); ++i)
+#else /* APPLE_CHANGES not defined */
+    for (int i = 0; i < value.length(); ++i)
+#endif /* APPLE_CHANGES not defined */
     {
       QChar c(value[i]);
       if (!c.isNumber() && c != '-' && !c.isSpace())
diff --git a/WebCore/khtml/khtmlview.h b/WebCore/khtml/khtmlview.h
index 76e848b..5b8e884 100644
--- a/WebCore/khtml/khtmlview.h
+++ b/WebCore/khtml/khtmlview.h
@@ -53,8 +53,9 @@ namespace khtml {
     void applyRule(RenderStyle *style, DOM::CSSProperty *prop, DOM::ElementImpl *e);
 };
 
+#ifdef APPLE_CHANGES
 #include "khtml_part.h"
-
+#endif /* APPLE_CHANGES */
 class KHTMLPart;
 class KHTMLViewPrivate;
 
@@ -172,12 +173,20 @@ public:
 
     static const QList<KHTMLView> *viewList() { return lstViews; }
 
-    virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
+signals:
+    void cleared();
 
+protected:
+    void clear();
+
+#ifdef APPLE_CHANGES
+public:
+#endif /* APPLE_CHANGES */
     virtual void resizeEvent ( QResizeEvent * event );
     virtual void showEvent ( QShowEvent * );
     virtual void hideEvent ( QHideEvent *);
     virtual bool focusNextPrevChild( bool next );
+    virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
 
     virtual void viewportMousePressEvent( QMouseEvent * );
     virtual void focusOutEvent( QFocusEvent * );
@@ -208,13 +217,6 @@ public:
      */
     void doAutoScroll();
 
-signals:
-    void cleared();
-
-    void clear();
-
-protected:
-
 protected slots:
     void slotPaletteChanged();
 
diff --git a/WebCore/khtml/misc/decoder.cpp b/WebCore/khtml/misc/decoder.cpp
index 89d0462..2927754 100644
--- a/WebCore/khtml/misc/decoder.cpp
+++ b/WebCore/khtml/misc/decoder.cpp
@@ -84,7 +84,7 @@ void Decoder::setEncoding(const char *_encoding, bool force)
     if( !b ) // in case the codec didn't exist, we keep the old one (fixes some sites specifying invalid codecs)
 	m_codec = old;
     else
-        haveEncoding = force;
+	haveEncoding = force;
     delete m_decoder;
     m_decoder = m_codec->makeDecoder();
 #ifdef DECODE_DEBUG
@@ -230,12 +230,12 @@ QString Decoder::decode(const char *data, int len)
             }
             return QString::null;
         }
-    } 
-#ifdef _KWQ_
+    }
+#ifdef APPLE_CHANGES
     else {
         buffer += QCString(data, len+1);
-    }
-#endif
+    } 
+#endif /* APPLE_CHANGES */
 
  found:
     // if we still haven't found an encoding latin1 will be used...
diff --git a/WebCore/khtml/misc/helper.cpp b/WebCore/khtml/misc/helper.cpp
index dca84ae..81658d4 100644
--- a/WebCore/khtml/misc/helper.cpp
+++ b/WebCore/khtml/misc/helper.cpp
@@ -153,16 +153,21 @@ using namespace khtml;
 
 static HTMLColors *htmlColors = 0L;
 
+#ifdef APPLE_CHANGES
 // FIXME: do we really need static delete support here?
-//static KStaticDeleter<HTMLColors> hcsd;
+#else /* APPLE_CHANGES not defined */
+static KStaticDeleter<HTMLColors> hcsd;
+#endif /* APPLE_CHANGES not defined */
 
 void khtml::setNamedColor(QColor &color, const QString &_name)
 {
-    if( !htmlColors ) {
+    if( !htmlColors )
+#ifdef APPLE_CHANGES
         // FIXME: do we really need static delete support here?
-        // htmlColors = hcsd.setObject( new HTMLColors );
         htmlColors = new HTMLColors();
-    }
+#else /* APPLE_CHANGES not defined */
+        htmlColors = hcsd.setObject( new HTMLColors );
+#endif /* APPLE_CHANGES not defined */
 
     int pos;
     QString name = _name;
@@ -180,16 +185,38 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
     // also recognize "color=ffffff"
     if (len == 6)
     {
+#ifdef APPLE_CHANGES
         // recognize #12345 (append a '0')
         if(name[0] == '#') {
             name += '0';
         }
         else if ((!name[0].isLetter() && !name[0].isDigit())) {
-            color = QColor();
-            return;
-	    }
-        
+	    color = QColor();
+	    return;
+	}
         color.setNamedColor(name);
+#else /* APPLE_CHANGES not defined */
+        bool ok;
+        int val = name.toInt(&ok, 16);
+        if(ok)
+        {
+            color.setRgb((0xff << 24) | val);
+            return;
+        }
+        // recognize #12345 (duplicate the last character)
+        if(name[0] == '#') {
+            bool ok;
+            int val = name.right(5).toInt(&ok, 16);
+            if(ok) {
+                color.setRgb((0xff << 24) | (val * 16 + ( val&0xf )));
+                return;
+            }
+        }
+        if ( !name[0].isLetter() ) {
+	    color = QColor();
+	    return;
+	}
+#endif /* APPLE_CHANGES not defined */
     }
 
     // #fffffff as found on msdn.microsoft.com
@@ -227,13 +254,11 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
     else
     {
         QColor tc = htmlColors->map[name];
-        
-        if (!tc.isValid()) {
+        if ( !tc.isValid() )
             tc = htmlColors->map[name.lower()];
-        }
-        if (tc.isValid()) {
+
+        if (tc.isValid())
             color = tc;
-        }
         else {
             color.setNamedColor(name);
             if ( !color.isValid() )  color.setNamedColor( name.lower() );
diff --git a/WebCore/khtml/misc/loader.h b/WebCore/khtml/misc/loader.h
index ec7edf0..df810a1 100644
--- a/WebCore/khtml/misc/loader.h
+++ b/WebCore/khtml/misc/loader.h
@@ -66,8 +66,10 @@ namespace khtml
 {
     class CachedObject;
     class Request;
+#ifdef APPLE_CHANGES
     class LoaderPrivate;
     class DocLoader;
+#endif /* APPLE_CHANGES */
 
     /**
      * @internal
@@ -96,9 +98,15 @@ namespace khtml
 	    Uncacheable   // to big to be cached,
 	};  	          // will be destroyed as soon as possible
 
+#ifdef APPLE_CHANGES
 	CachedObject(const DocLoader *loader, const DOM::DOMString &url, Type type, bool _reload, int _expireDate)
+#else /* APPLE_CHANGES not defined */
+	CachedObject(const DOM::DOMString &url, Type type, bool _reload, int _expireDate)
+#endif /* APPLE_CHANGES not defined */
 	{
+#ifdef APPLE_CHANGES
 	    m_loader = loader;
+#endif /* APPLE_CHANGES */
 	    m_url = url;
 	    m_type = type;
 	    m_status = Pending;
@@ -107,12 +115,12 @@ namespace khtml
 	    m_reload = _reload;
 	    m_request = 0;
 	    m_expireDate = _expireDate;
-        m_deleted = false;
+            m_deleted = false;
 	}
 	virtual ~CachedObject() {
-        if(m_deleted) abort();
+            if(m_deleted) abort();
             m_deleted = true;
-    }
+        }
 
 	virtual void data( QBuffer &buffer, bool eof) = 0;
 	virtual void error( int err, const char *text ) = 0;
@@ -137,47 +145,47 @@ namespace khtml
 	 */
 	void finish();
 
-    /*
-     * Called by the cache if the object has been removed from the cache dict
-     * while still being referenced. This means the object should kill itself
-     * if its reference counter drops down to zero.
-     */
-    void setFree( bool b ) { m_free = b; }
-    
-    bool reload() const { return m_reload; }
-    
-    void setRequest(Request *_request);
-    
-    bool canDelete() const { return (m_clients.count() == 0 && !m_request); }
+        /*
+         * Called by the cache if the object has been removed from the cache dict
+         * while still being referenced. This means the object should kill itself
+         * if its reference counter drops down to zero.
+         */
+        void setFree( bool b ) { m_free = b; }
 
-	void setExpireDate(int _expireDate);
+        bool reload() const { return m_reload; }
 
-    /*
-     * List of acceptable mimetypes seperated by ",". A mimetype may contain a wildcard.
-     */
-    // e.g. "text/*"
-    QString accept() const { return m_accept; }
-    void setAccept(const QString &_accept) { m_accept = _accept; }
+        void setRequest(Request *_request);
 
+        bool canDelete() const { return (m_clients.count() == 0 && !m_request); }
+
+	void setExpireDate(int _expireDate);
 
+        /*
+         * List of acceptable mimetypes seperated by ",". A mimetype may contain a wildcard.
+         */
+        // e.g. "text/*"
+        QString accept() const { return m_accept; }
+        void setAccept(const QString &_accept) { m_accept = _accept; }
+#ifdef APPLE_CHANGES
     const DocLoader *loader() { return m_loader; }
-    
-    protected:
+#endif /* APPLE_CHANGES */
 
-    const DocLoader *m_loader;
-    
-    QList<CachedObjectClient> m_clients;
+    protected:
+#ifdef APPLE_CHANGES
+        const DocLoader *m_loader;
+#endif /* APPLE_CHANGES */
+        QList<CachedObjectClient> m_clients;
         
 	DOM::DOMString m_url;
-    QString m_accept;
-    Request *m_request;
+        QString m_accept;
+        Request *m_request;
 	Type m_type;
 	Status m_status;
 	int m_size;
 	int m_expireDate;
-    bool m_free;
-    bool m_reload;
-    bool m_deleted;
+        bool m_free;
+        bool m_reload;
+        bool m_deleted;
     };
 
 
@@ -187,7 +195,11 @@ namespace khtml
     class CachedCSSStyleSheet : public CachedObject
     {
     public:
+#ifdef APPLE_CHANGES
 	CachedCSSStyleSheet(const DocLoader *loader, const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate, const QString& charset);
+#else /* APPLE_CHANGES not defined */
+	CachedCSSStyleSheet(const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate, const QString& charset);
+#endif /* APPLE_CHANGES not defined */
 	virtual ~CachedCSSStyleSheet();
 
 	const DOM::DOMString &sheet() const { return m_sheet; }
@@ -212,7 +224,11 @@ namespace khtml
     class CachedScript : public CachedObject
     {
     public:
+#ifdef APPLE_CHANGES
 	CachedScript(const DocLoader *loader, const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate, const QString& charset);
+#else /* APPLE_CHANGES not defined */
+	CachedScript(const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate, const QString& charset);
+#endif /* APPLE_CHANGES not defined */
 	virtual ~CachedScript();
 
 	const DOM::DOMString &script() const { return m_script; }
@@ -240,7 +256,11 @@ namespace khtml
     {
 	Q_OBJECT
     public:
+#ifdef APPLE_CHANGES
 	CachedImage(const DocLoader *loader, const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate);
+#else /* APPLE_CHANGES not defined */
+	CachedImage(const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate);
+#endif /* APPLE_CHANGES not defined */
 	virtual ~CachedImage();
 
 	const QPixmap &pixmap() const;
@@ -322,7 +342,9 @@ namespace khtml
         void setReloading( bool );
         void setShowAnimations( bool );
         void removeCachedObject( CachedObject*) const;
+#ifdef APPLE_CHANGES
         const KHTMLPart *part() { return m_part; }
+#endif /* APPLE_CHANGES */
 
     private:
         friend class Cache;
@@ -349,9 +371,9 @@ namespace khtml
 	QBuffer m_buffer;
 	CachedObject *object;
 	DOM::DOMString m_baseURL;
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void *client;
-#endif
+#endif /* APPLE_CHANGES */
     };
 
     /**
@@ -379,15 +401,15 @@ namespace khtml
 	void requestDone( const DOM::DOMString &baseURL, khtml::CachedObject *obj );
 	void requestFailed( const DOM::DOMString &baseURL, khtml::CachedObject *obj );
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     public:
 	void slotFinished( KIO::Job * );
 	void slotData( KIO::Job *, const char *data, int size );
-#else
+#else /* APPLE_CHANGES not defined */
     protected slots:
 	void slotFinished( KIO::Job * );
 	void slotData( KIO::Job *, const QByteArray & );
-#endif
+#endif /* APPLE_CHANGES not defined */
 
     private:
 	void servePendingRequests();
@@ -397,13 +419,13 @@ namespace khtml
 #ifdef HAVE_LIBJPEG
         KJPEGFormatType m_jpegloader;
 #endif
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 #if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
     LoaderPrivate *d;
-#else
+#else /* __APPLE__, __OBJC__, __cplusplus not defined */
     void *d;    
-#endif // __APPLE__, __OBJC__, __cplusplus
-#endif // _KWQ_
+#endif /* __APPLE__, __OBJC__, __cplusplus not defined */
+#endif /* APPLE_CHANGES */
     };
 
         /**
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index f97de56..2dc0114 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -851,11 +851,11 @@ void RenderFlow::layoutInlineChildren()
             if(!m_pre) {
                 // remove leading spaces
 #ifndef QT_NO_UNICODETABLES
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
                 while(!start.atEnd() && start.current() == ' ' )
-#else
+#else /* APPLE_CHANGES not defined */
                 while(!start.atEnd() && start.direction() == QChar::DirWS )
-#endif
+#endif /* APPLE_CHANGES not defined */
 #else
                 while(!start.atEnd() && start.current() == ' ' )
 #endif
diff --git a/WebCore/khtml/rendering/render_applet.cpp b/WebCore/khtml/rendering/render_applet.cpp
index 47c4dd7..0e2be5b 100644
--- a/WebCore/khtml/rendering/render_applet.cpp
+++ b/WebCore/khtml/rendering/render_applet.cpp
@@ -35,10 +35,9 @@
 #include <java/kjavaappletwidget.h>
 #include <misc/htmltags.h>
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 #include <WCJavaAppletWidget.h>
-#endif
-
+#endif /* APPLE_CHANGES */
 using namespace khtml;
 using namespace DOM;
 
@@ -49,10 +48,10 @@ RenderApplet::RenderApplet(QScrollView *view,
     // init RenderObject attributes
     setInline(true);
     m_applet = applet;
-    
-#ifdef _KWQ_
+
+#ifdef APPLE_CHANGES
     setQWidget( new WCJavaAppletWidget(args));
-#else
+#else /* APPLE_CHANGES not defined */
     KJavaAppletContext *context = 0;
     KHTMLView *_view = static_cast<KHTMLView*>(view);
     if ( _view ) {
@@ -65,7 +64,7 @@ RenderApplet::RenderApplet(QScrollView *view,
         setQWidget( new KJavaAppletWidget(context, view->viewport()) );
         processArguments(args);
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
 }
 
 RenderApplet::~RenderApplet()
@@ -102,11 +101,11 @@ void RenderApplet::layout()
 
     calcWidth();
     calcHeight();
-    
-#ifdef _KWQ_
+
+#ifdef APPLE_CHANGES
     m_widget->resize(m_width-marginLeft()-marginRight()-paddingLeft()-paddingRight(),
         m_height-marginTop()-marginBottom()-paddingTop()-paddingBottom());
-#else
+#else /* APPLE_CHANGES not defined */
     KJavaAppletWidget *tmp = static_cast<KJavaAppletWidget*>(m_widget);
     if ( tmp ) {
         NodeImpl *child = m_applet->firstChild();
@@ -125,7 +124,8 @@ void RenderApplet::layout()
                          m_height-marginTop()-marginBottom()-paddingTop()-paddingBottom());
         tmp->showApplet();
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
+
     setLayouted();
 }
 
diff --git a/WebCore/khtml/rendering/render_body.cpp b/WebCore/khtml/rendering/render_body.cpp
index c5b9f91..a5f2f59 100644
--- a/WebCore/khtml/rendering/render_body.cpp
+++ b/WebCore/khtml/rendering/render_body.cpp
@@ -96,8 +96,10 @@ void RenderBody::layout()
     {
         if (root()->view())
         {
-            //root()->view()->horizontalScrollBar()->setPalette(style()->palette());
-            //root()->view()->verticalScrollBar()->setPalette(style()->palette());
+#ifndef APPLE_CHANGES
+            root()->view()->horizontalScrollBar()->setPalette(style()->palette());
+            root()->view()->verticalScrollBar()->setPalette(style()->palette());
+#endif /* APPLE_CHANGES not defined */
         }
         scrollbarsStyled=true;
     }
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index 1d6605f..b23829f 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -207,7 +207,6 @@ void RenderBox::printBackground(QPainter *p, const QColor &c, CachedImage *bg, i
     if(c.isValid())
         p->fillRect(_tx, clipy, w, cliph, c);
     // no progressive loading of the background image
-    
     if(bg && bg->pixmap_size() == bg->valid_rect().size() && !bg->isTransparent() && !bg->isErrorImage()) {
         //kdDebug( 6040 ) << "printing bgimage at " << _tx << "/" << _ty << endl;
         // ### might need to add some correct offsets
@@ -296,15 +295,14 @@ void RenderBox::printBackground(QPainter *p, const QColor &c, CachedImage *bg, i
 
 //        kdDebug() << "cx="<<cx << " cy="<<cy<< " cw="<<cw << " ch="<<ch << " sx="<<sx << " sy="<<sy << endl;
         
-        if (cw>0 && ch>0) {
-#ifdef _KWQ_
+        if (cw>0 && ch>0)
+#ifdef APPLE_CHANGES
             // This is a change in behavior. The difference is that we 
             // do not do a fill of the passed in color before tiling.
             p->drawTiledPixmap(cx, cy, cw, ch, bg->pixmap(), sx, sy);
-#else
+#else /* APPLE_CHANGES not defined */
             p->drawTiledPixmap(cx, cy, cw, ch, bg->tiled_pixmap(c), sx, sy);
-#endif
-        }
+#endif /* APPLE_CHANGES not defined */
     }
 }
 
diff --git a/WebCore/khtml/rendering/render_flow.cpp b/WebCore/khtml/rendering/render_flow.cpp
index 6c5b65a..5f27411 100644
--- a/WebCore/khtml/rendering/render_flow.cpp
+++ b/WebCore/khtml/rendering/render_flow.cpp
@@ -137,7 +137,9 @@ void RenderFlow::print(QPainter *p, int _x, int _y, int _w, int _h,
         if((_ty > _y + _h) || (_ty + h < _y))
         {
             //kdDebug( 6040 ) << "cut!" << endl;
-            //return;
+#ifndef APPLE_CHANGES
+            return;
+#endif /* APPLE_CHANGES not defined */
         }
     }
         
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 025a870..74783f4 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -22,6 +22,7 @@
  *
  * $Id$
  */
+
 #include <kdebug.h>
 #include <kurl.h>
 #include <klocale.h>
@@ -73,7 +74,11 @@ RenderFormElement::~RenderFormElement()
 
 short RenderFormElement::baselinePosition( bool f ) const
 {
+#ifdef APPLE_CHANGES
     return RenderWidget::baselinePosition( f ) - 6 - QFontMetrics( style()->font() ).descent();
+#else /* APPLE_CHANGES not defined */
+    return RenderWidget::baselinePosition( f ) - 2 - QFontMetrics( style()->font() ).descent();
+#endif /* APPLE_CHANGES not defined */
 }
 
 short RenderFormElement::calcReplacedWidth(bool*) const
@@ -258,6 +263,7 @@ bool RenderFormElement::eventFilter(QObject* /*o*/, QEvent* e)
     return deleted;
 }
 
+#ifdef APPLE_CHANGES
 void RenderFormElement::performAction(QObject::Actions action)
 {
     //fprintf (stdout, "RenderFormElement::performAction():  %d\n", action);
@@ -269,9 +275,12 @@ void RenderFormElement::performAction(QObject::Actions action)
         slotClicked();
 }
 
+#endif /* APPLE_CHANGES */
 void RenderFormElement::slotClicked()
 {
+#ifdef APPLE_CHANGES
     //fprintf (stdout, "RenderFormElement::slotClicked():\n");
+#endif /* APPLE_CHANGES */
     if(isRenderButton()) {
         QMouseEvent e2( QEvent::MouseButtonRelease, m_mousePos, m_button, m_state);
 
@@ -322,9 +331,13 @@ RenderCheckBox::RenderCheckBox(QScrollView *view,
     b->setMouseTracking(true);
     setQWidget(b);
     b->installEventFilter(this);
-
+#ifdef APPLE_CHANGES
     connect(b, "SIGNAL(stateChanged(int))", this, "SLOT(slotStateChanged(int))");
     connect(b, "SIGNAL(clicked())", this, "SLOT(slotClicked())");
+#else /* APPLE_CHANGES not defined */
+    connect(b,SIGNAL(stateChanged(int)),this,SLOT(slotStateChanged(int)));
+    connect(b, SIGNAL(clicked()), this, SLOT(slotClicked()));
+#endif /* APPLE_CHANGES not defined */
 }
 
 
@@ -349,7 +362,7 @@ void RenderCheckBox::layout()
     RenderButton::layout();
 }
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 void RenderCheckBox::performAction(QObject::Actions action)
 {
     QCheckBox* cb = static_cast<QCheckBox*>( m_widget );
@@ -358,11 +371,10 @@ void RenderCheckBox::performAction(QObject::Actions action)
     if (action == QObject::ACTION_CHECKBOX_CLICKED)
         slotStateChanged(cb->isChecked() ? 2 : 0);
 }
-#endif
-
 
 // From the Qt documentation:
 // state is 2 if the button is on, 1 if it is in the "no change" state or 0 if the button is off. 
+#endif /* APPLE_CHANGES */
 void RenderCheckBox::slotStateChanged(int state)
 {
     m_element->setAttribute(ATTR_CHECKED,state == 2 ? "" : 0);
@@ -379,7 +391,11 @@ RenderRadioButton::RenderRadioButton(QScrollView *view,
     b->setMouseTracking(true);
     setQWidget(b);
     b->installEventFilter(this);
+#ifdef APPLE_CHANGES
     connect(b, "SIGNAL(clicked())", this, "SLOT(slotClicked())");
+#else /* APPLE_CHANGES not defined */
+    connect(b, SIGNAL(clicked()), this, SLOT(slotClicked()));
+#endif /* APPLE_CHANGES not defined */
 }
 
 void RenderRadioButton::setChecked(bool checked)
@@ -389,8 +405,9 @@ void RenderRadioButton::setChecked(bool checked)
 
 void RenderRadioButton::slotClicked()
 {
+#ifdef APPLE_CHANGES
     //fprintf (stdout, "RenderRadioButton::slotClicked():\n");
-
+#endif /* APPLE_CHANGES */
     m_element->setAttribute(ATTR_CHECKED,"");
 
     // emit mouseClick event etc
@@ -428,12 +445,16 @@ RenderSubmitButton::RenderSubmitButton(QScrollView *view, HTMLInputElementImpl *
     setQWidget(p);
     p->setMouseTracking(true);
     p->installEventFilter(this);
+#ifdef APPLE_CHANGES
     connect(p, "SIGNAL(clicked())", this, "SLOT(slotClicked())");
     
     // Need to store a reference to this object and then invoke slotClicked on it.
     //p->setAction (&RenderFormElement::slotClicked);
     //p->setRenderObject (this);
     p->setTarget (this);
+#else /* APPLE_CHANGES not defined */
+    connect(p, SIGNAL(clicked()), this, SLOT(slotClicked()));
+#endif /* APPLE_CHANGES not defined */
 }
 
 void RenderSubmitButton::calcMinMaxWidth()
@@ -476,10 +497,14 @@ QString RenderSubmitButton::defaultLabel() {
 
 short RenderSubmitButton::baselinePosition( bool f ) const
 {
+#ifdef APPLE_CHANGES
     //return RenderFormElement::baselinePosition( f );
     // FIXED: [rjw] Where does this magic number '8' come from.  It's also used above in
     // RenderSubmitButton::calcMinMaxWidth().
     return RenderWidget::baselinePosition( f ) - 8 - QFontMetrics( style()->font() ).descent();
+#else /* APPLE_CHANGES not defined */
+    return RenderFormElement::baselinePosition( f );
+#endif /* APPLE_CHANGES not defined */
 }
 
 // -------------------------------------------------------------------------------
@@ -552,11 +577,13 @@ RenderLineEdit::RenderLineEdit(QScrollView *view, HTMLInputElementImpl *element)
 {
     LineEditWidget *edit = new LineEditWidget(view->viewport());
     edit->installEventFilter(this);
-
-#ifdef _KWQ_    
+#ifdef APPLE_CHANGES
     connect(edit,"SIGNAL(returnPressed())", this, "SLOT(slotReturnPressed())");
     connect(edit,"SIGNAL(textChanged(const QString &))", this, "SLOT(slotTextChanged(const QString &))");
-#endif
+#else /* APPLE_CHANGES not defined */
+    connect(edit,SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
+    connect(edit,SIGNAL(textChanged(const QString &)),this,SLOT(slotTextChanged(const QString &)));
+#endif /* APPLE_CHANGES not defined */
 
     if(element->inputType() == HTMLInputElementImpl::PASSWORD)
         edit->setEchoMode( QLineEdit::Password );
@@ -570,14 +597,12 @@ RenderLineEdit::RenderLineEdit(QScrollView *view, HTMLInputElementImpl *element)
         }
     }
 
-#ifdef _KWQ_
     setQWidget(edit);
-
+#ifdef APPLE_CHANGES
     edit->setTarget (this);
-#endif
+#endif /* APPLE_CHANGES */
 }
 
-
 void RenderLineEdit::slotReturnPressed()
 {
     // don't submit the form when return was pressed in a completion-popup
@@ -617,7 +642,11 @@ void RenderLineEdit::calcMinMaxWidth()
             h = 22;
         s = QSize( w + 8, h ).expandedTo( QApplication::globalStrut() );
     } else
+#ifdef APPLE_CHANGES
 	s = QSize( w + 6, h + 6 ).expandedTo( QApplication::globalStrut() );
+#else /* APPLE_CHANGES not defined */
+	s = QSize( w + 4, h + 4 ).expandedTo( QApplication::globalStrut() );
+#endif /* APPLE_CHANGES not defined */
 
     setIntrinsicWidth( s.width() );
     setIntrinsicHeight( s.height() );
@@ -647,7 +676,7 @@ void RenderLineEdit::layout()
     RenderFormElement::layout();
 }
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 void RenderLineEdit::performAction(QObject::Actions action)
 {
     KLineEdit *edit = static_cast<KLineEdit*>(m_widget);
@@ -658,8 +687,8 @@ void RenderLineEdit::performAction(QObject::Actions action)
     else if (action == QObject::ACTION_TEXT_FIELD)
         slotReturnPressed();
 }
-#endif
 
+#endif /* APPLE_CHANGES */
 void RenderLineEdit::slotTextChanged(const QString &string)
 {
     // don't use setValue here!
@@ -690,12 +719,21 @@ RenderFileButton::RenderFileButton(QScrollView *view, HTMLInputElementImpl *elem
 
     m_edit->installEventFilter(this);
 
+#ifdef APPLE_CHANGES
     connect(m_edit, "SIGNAL(returnPressed())", this, "SLOT(slotReturnPressed())");
     connect(m_edit, "SIGNAL(textChanged(const QString &))", this, "SLOT(slotTextChanged(const QString &))");
+#else /* APPLE_CHANGES not defined */
+    connect(m_edit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
+    connect(m_edit, SIGNAL(textChanged(const QString &)),this,SLOT(slotTextChanged(const QString &)));
+#endif /* APPLE_CHANGES not defined */
 
     m_button = new QPushButton(i18n("Browse..."), w);
     m_button->setFocusPolicy(QWidget::ClickFocus);
+#ifdef APPLE_CHANGES
     connect(m_button, "SIGNAL(clicked())", this, "SLOT(slotClicked())");
+#else /* APPLE_CHANGES not defined */
+    connect(m_button,SIGNAL(clicked()), this, SLOT(slotClicked()));
+#endif /* APPLE_CHANGES not defined */
 
     w->setStretchFactor(m_edit, 2);
     w->setFocusProxy(m_edit);
@@ -860,7 +898,7 @@ RenderSelect::RenderSelect(QScrollView *view, HTMLSelectElementImpl *element)
     if(m_useListBox)
         setQWidget(createListBox());
     else
-	    setQWidget(createComboBox());
+	setQWidget(createComboBox());
 }
 
 
@@ -934,7 +972,8 @@ void RenderSelect::layout( )
 
                 if(m_useListBox) {
                     QListBoxText *item = new QListBoxText(QString(text.implementation()->s, text.implementation()->l).visual());
-                    static_cast<KListBox*>(m_widget)->insertItem(item, listIndex);
+                    static_cast<KListBox*>(m_widget)
+                        ->insertItem(item, listIndex);
                     item->setSelectable(false);
                 }
                 else
@@ -988,16 +1027,16 @@ void RenderSelect::layout( )
         if(size < 1)
             size = QMIN(static_cast<KListBox*>(m_widget)->count(), 10);
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
         width += w->scrollBarWidth();
         height = size*height;
         // NSBrowser has problems drawing scrollbar correctly when it's size is too small.
         if (height < 60)
             height = 60;
-#else
+#else /* APPLE_CHANGES not defined */
         width += 2*w->frameWidth() + w->verticalScrollBar()->sizeHint().width();
         height = size*height + 2*w->frameWidth();
-#endif
+#endif /* APPLE_CHANGES not defined */
 
         setIntrinsicWidth( width );
         setIntrinsicHeight( height );
@@ -1082,6 +1121,7 @@ void RenderSelect::slotSelected(int index)
 }
 
 
+#ifdef APPLE_CHANGES
 void RenderSelect::performAction(QObject::Actions action)
 {
     //fprintf (stdout, "RenderSelect::performAction():  %d\n", action);
@@ -1094,6 +1134,7 @@ void RenderSelect::performAction(QObject::Actions action)
     }
 }
 
+#endif /* APPLE_CHANGES */
 void RenderSelect::slotSelectionChanged()
 {
     if ( m_ignoreSelectEvents ) return;
@@ -1122,7 +1163,11 @@ KListBox* RenderSelect::createListBox()
     lb->setSelectionMode(m_multiple ? QListBox::Extended : QListBox::Single);
     // ### looks broken
     //lb->setAutoMask(true);
+#ifdef APPLE_CHANGES
     connect( lb, "SIGNAL(selectionChanged())", this, "SLOT(slotSelectionChanged())" );
+#else /* APPLE_CHANGES not defined */
+    connect( lb, SIGNAL( selectionChanged() ), this, SLOT( slotSelectionChanged() ) );
+#endif /* APPLE_CHANGES not defined */
     m_ignoreSelectEvents = false;
     lb->setMouseTracking(true);
 
@@ -1133,7 +1178,11 @@ ComboBoxWidget *RenderSelect::createComboBox()
 {
     ComboBoxWidget *cb = new ComboBoxWidget(m_view->viewport());
     cb->installEventFilter(this);
+#ifdef APPLE_CHANGES
     connect(cb, "SIGNAL(activated(int))", this, "SLOT(slotSelected(int))");
+#else /* APPLE_CHANGES not defined */
+    connect(cb, SIGNAL(activated(int)), this, SLOT(slotSelected(int)));
+#endif /* APPLE_CHANGES not defined */
     return cb;
 }
 
@@ -1214,7 +1263,11 @@ RenderTextArea::RenderTextArea(QScrollView *view, HTMLTextAreaElementImpl *eleme
     setQWidget(edit);
     edit->installEventFilter(this);
 
+#ifdef APPLE_CHANGES
     connect(edit, "SIGNAL(textChanged())", this, "SLOT(slotTextChanged())");
+#else /* APPLE_CHANGES not defined */
+    connect(edit,SIGNAL(textChanged()),this,SLOT(slotTextChanged()));
+#endif /* APPLE_CHANGES not defined */
 }
 
 RenderTextArea::~RenderTextArea()
@@ -1232,21 +1285,21 @@ void RenderTextArea::calcMinMaxWidth()
     TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
     HTMLTextAreaElementImpl* f = static_cast<HTMLTextAreaElementImpl*>(m_element);
     QFontMetrics m = fontMetrics(style()->font());
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     QSize size( QMAX(f->cols(), 1)*m.width('x') + w->frameWidth()*5 +
                 w->verticalScrollBarWidth(),
                 QMAX(f->rows(), 1)*m.height() + w->frameWidth()*3 +
                 (w->wordWrap() == QMultiLineEdit::NoWrap ?
                  w->horizontalScrollBarHeight() : 0)
         );
-#else
+#else /* APPLE_CHANGES not defined */
     QSize size( QMAX(f->cols(), 1)*m.width('x') + w->frameWidth()*5 +
                 w->verticalScrollBar()->sizeHint().width(),
                 QMAX(f->rows(), 1)*m.height() + w->frameWidth()*3 +
                 (w->wordWrap() == QMultiLineEdit::NoWrap ?
                  w->horizontalScrollBar()->sizeHint().height() : 0)
         );
-#endif
+#endif /* APPLE_CHANGES not defined */
 
     setIntrinsicWidth( size.width() );
     setIntrinsicHeight( size.height() );
@@ -1260,13 +1313,13 @@ void RenderTextArea::layout( )
     HTMLTextAreaElementImpl* f = static_cast<HTMLTextAreaElementImpl*>(m_element);
 
     if (!layouted()) {
-        w->setReadOnly(m_element->readOnly());
-        w->blockSignals(true);
-        int line, col;
-        w->getCursorPosition( &line, &col );
-        w->setText(f->value().string().visual());
-        w->setCursorPosition( line, col );
-        w->blockSignals(false);
+	w->setReadOnly(m_element->readOnly());
+	w->blockSignals(true);
+	int line, col;
+	w->getCursorPosition( &line, &col );
+	w->setText(f->value().string().visual());
+	w->setCursorPosition( line, col );
+	w->blockSignals(false);
     }
 
     RenderFormElement::layout();
@@ -1301,6 +1354,7 @@ QString RenderTextArea::text()
     return txt;
 }
 
+#ifdef APPLE_CHANGES
 void RenderTextArea::performAction(QObject::Actions action)
 {
     //TextAreaWidget *edit = static_cast<TextAreaWidget*>(m_widget);
@@ -1310,6 +1364,7 @@ void RenderTextArea::performAction(QObject::Actions action)
         slotTextChanged();
 }
 
+#endif /* APPLE_CHANGES */
 void RenderTextArea::slotTextChanged()
 {
     static_cast<HTMLTextAreaElementImpl*>( m_element )->m_dirtyvalue = true;
diff --git a/WebCore/khtml/rendering/render_form.h b/WebCore/khtml/rendering/render_form.h
index 9c9713b..2cb9d24 100644
--- a/WebCore/khtml/rendering/render_form.h
+++ b/WebCore/khtml/rendering/render_form.h
@@ -83,10 +83,9 @@ public:
     DOM::HTMLGenericFormElementImpl *element() { return m_element; }
 
     virtual bool eventFilter(QObject*, QEvent*);
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
+#endif /* APPLE_CHANGES */
 
 public slots:
     virtual void slotClicked();
@@ -133,10 +132,9 @@ public:
     virtual const char *renderName() const { return "RenderCheckBox"; }
     virtual void calcMinMaxWidth();
     virtual void layout( );
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
+#endif /* APPLE_CHANGES */
     
 public slots:
     virtual void slotStateChanged(int state);
@@ -225,10 +223,9 @@ public:
 
     virtual const char *renderName() const { return "RenderLineEdit"; }
     void select();
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
+#endif /* APPLE_CHANGES */
 
 public slots:
     void slotReturnPressed();
@@ -341,11 +338,9 @@ public:
     void setSelectionChanged(bool _selectionChanged) { m_selectionChanged = _selectionChanged; }
 
     void updateSelection();
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
-
+#endif /* APPLE_CHANGES */
 
 protected:
     KListBox *createListBox();
@@ -395,10 +390,9 @@ public:
 
     QString text(); // ### remove
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
-
+#endif /* APPLE_CHANGES */
     void select();
 
 protected slots:
diff --git a/WebCore/khtml/rendering/render_frames.cpp b/WebCore/khtml/rendering/render_frames.cpp
index 513a538..dc57e64 100644
--- a/WebCore/khtml/rendering/render_frames.cpp
+++ b/WebCore/khtml/rendering/render_frames.cpp
@@ -804,11 +804,12 @@ void RenderPartObject::updateWidget()
      }
 
      KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();
-     #ifdef _KWQ_
-     #else
+
+#ifndef APPLE_CHANGES
      o->param.append( QString::fromLatin1("__KHTML__PLUGINEMBED=\"YES\"") );
      o->param.append( QString::fromLatin1("__KHTML__PLUGINBASEURL=\"%1\"").arg( part->url().url() ) );
-     #endif
+#endif /* APPLE_CHANGES not defined */
+
      part->requestObject( this, url, serviceType, o->param );
 
   } else {
diff --git a/WebCore/khtml/rendering/render_hr.cpp b/WebCore/khtml/rendering/render_hr.cpp
index 7b9829d..3f2d67f 100644
--- a/WebCore/khtml/rendering/render_hr.cpp
+++ b/WebCore/khtml/rendering/render_hr.cpp
@@ -69,9 +69,12 @@ void RenderHR::print(QPainter *p, int _x, int _y, int _w, int _h, int _tx, int _
         prev = prev->previousSibling();
     if(prev && static_cast<RenderFlow *>(prev)->floatBottom() > prev->height() )
         xp += static_cast<RenderFlow *>(prev)->leftOffset( prev->height() );
-    
+
+#ifdef APPLE_CHANGES
     // [kocienda] yp is unused because of #if 0 block
-    //int yp = _ty ;
+#else /* APPLE_CHANGES not defined */
+    int yp = _ty ;
+#endif /* APPLE_CHANGES not defined */
 
 
 
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index ffa0812..62f8015 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -170,11 +170,11 @@ void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
         if(cWidth > 2 && cHeight > 2)
         {
             //qDebug("qDrawShadePanel %d/%d/%d/%d", _tx + leftBorder, _ty + topBorder, cWidth, cHeight);
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
             p->setPen (Qt::lightGray);
             p->setBrush (Qt::NoBrush);
             p->drawRect (_tx, _ty, cWidth, cHeight);
-#else
+#else /* APPLE_CHANGES not defined */
             qDrawShadePanel( p, _tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight,
                              KApplication::palette().inactive(), true, 1 );
             if(berrorPic && !pix.isNull() && (cWidth >= pix.width()+4) && (cHeight >= pix.height()+4) )
@@ -196,7 +196,7 @@ void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
                 if (aw>15 && ah>fm.height())
                     p->drawText(ax, ay, aw, ah , Qt::WordBreak, text );
             }
-#endif
+#endif /* APPLE_CHANGES not defined */
         }
     }
     else if (image && !image->isTransparent())
diff --git a/WebCore/khtml/rendering/render_list.cpp b/WebCore/khtml/rendering/render_list.cpp
index 3429f88..2395081 100644
--- a/WebCore/khtml/rendering/render_list.cpp
+++ b/WebCore/khtml/rendering/render_list.cpp
@@ -246,13 +246,13 @@ void RenderListMarker::printObject(QPainter *p, int, int,
     p->setFont(style()->font());
     p->setPen(style()->color());
     QFontMetrics fm = p->fontMetrics();
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     // Why does khtml draw such large dots, squares, circle, etc for list items?
     // These seem much bigger than competing browsers.  I've reduced the size.
     int offset = fm.ascent()/3;
-#else
+#else /* APPLE_CHANGES not defined */
     int offset = fm.ascent()*2/3;
-#endif
+#endif /* APPLE_CHANGES not defined */
 
 #ifdef BOX_DEBUG
     p->setPen( QColor("red") );
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index 40e352d..9c7e5b5 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -190,7 +190,9 @@ public:
     {
 	width = 3; // medium is default value
 	style = BNONE;
+#ifdef APPLE_CHANGES
 	color = Qt::black;
+#endif /* APPLE_CHANGES */
     }
     QColor color;
     unsigned short width : 12;
diff --git a/WebCore/khtml/rendering/render_table.cpp b/WebCore/khtml/rendering/render_table.cpp
index 20fee35..3ee0061 100644
--- a/WebCore/khtml/rendering/render_table.cpp
+++ b/WebCore/khtml/rendering/render_table.cpp
@@ -729,8 +729,11 @@ void RenderTable::calcFinalColMax(int c, ColInfo* col)
         oldmin+=colMinWidth[o];
     }
 
+#ifdef APPLE_CHANGES
     // [kocienda] smin in unused
-    //int smin = col->min;
+#else /* APPLE_CHANGES not defined */
+    int smin = col->min;
+#endif /* APPLE_CHANGES not defined */
     int smax = col->max;
 
     if (col->type == Percent)
@@ -1358,8 +1361,12 @@ void RenderTable::layoutRows(int yoff)
                 continue;
             if ( c < totalCols - 1 && cell == cells[r][c+1] )
                 continue;
+#ifdef APPLE_CHANGES
             // [kocienda] fixed signed/unsigned comparison
             if ( (int)r < (int)totalRows - 1 && cell == cells[r+1][c] )
+#else /* APPLE_CHANGES not defined */
+            if ( r < (int)totalRows - 1 && cell == cells[r+1][c] )
+#endif /* APPLE_CHANGES not defined */
                 continue;
 
     	    cell->calcVerticalMargins();
@@ -1380,8 +1387,11 @@ void RenderTable::layoutRows(int yoff)
     else if (h.isPercent())
     {
         Length ch = containingBlock()->style()->height();
+#ifdef APPLE_CHANGES
         // [kocienda] containing is unused
-        //RenderObject *containing = containingBlock();
+#else /* APPLE_CHANGES not defined */
+        RenderObject *containing = containingBlock();
+#endif /* APPLE_CHANGES not defined */
         if (ch.isFixed())
             th = h.width(ch.value);
         else 
@@ -1428,8 +1438,12 @@ void RenderTable::layoutRows(int yoff)
                 continue;
             if ( c < totalCols - 1 && cell == cells[r][c+1] )
                 continue;
+#ifdef APPLE_CHANGES
             // [kocienda] fixed signed/unsigned comparison
             if ( (int)r < (int)totalRows - 1 && cell == cells[r+1][c] )
+#else /* APPLE_CHANGES not defined */
+            if ( r < (int)totalRows - 1 && cell == cells[r+1][c] )
+#endif /* APPLE_CHANGES not defined */
                 continue;
 
             if ( ( indx = c-cell->colSpan()+1 ) < 0 )
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 149311c..f9ef877 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -107,30 +107,30 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
     int width = m_width;
 
     if( begin )
- 	    width -= p->paddingLeft() + p->borderLeft();
+ 	width -= p->paddingLeft() + p->borderLeft();
 
     if ( end )
         width -= p->paddingRight() + p->borderRight();
 
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     //int underlineOffset = pt->fontMetrics().baselineOffset() + 2;
-#else
+#else /* APPLE_CHANGES not defined */
     int underlineOffset = ( pt->fontMetrics().height() + m_baseline ) / 2;
     if(underlineOffset <= m_baseline) underlineOffset = m_baseline+1;
-#endif
+#endif /* APPLE_CHANGES not defined */
 
-    if(deco & UNDERLINE){
+    if(deco & UNDERLINE)
+#ifdef APPLE_CHANGES
+    {
         //fprintf (stderr, "UNDERLINE (%d, %d) to (%d, %d)\n", _tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
-#ifdef _KWQ_
         QConstString s(m_text, m_len);
         pt->drawUnderlineForText(_tx, _ty + m_baseline, s.string());
-#else
-        pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
-#endif
         //pt->drawLine(_tx, _ty, _tx + width, _ty );
         //pt->drawLine(_tx, _ty + pt->fontMetrics().height(), _tx + width, _ty + pt->fontMetrics().height() );
     }
+#else /* APPLE_CHANGES not defined */
+        pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
+#endif /* APPLE_CHANGES not defined */
     if(deco & OVERLINE)
         pt->drawLine(_tx, _ty, _tx + width, _ty );
     if(deco & LINE_THROUGH)
@@ -265,7 +265,11 @@ int TextSlaveArray::findFirstMatching(Item d) const
 	if ( (*this)[mid] == 0 )			// null item greater
 	    res = -1;
 	else
+#ifdef APPLE_CHANGES
 	    res = ((TextSlaveArray*)this)->compareItems( d, (*this)[mid] );
+#else /* APPLE_CHANGES not defined */
+	    res = ((QGVector*)this)->compareItems( d, (*this)[mid] );
+#endif /* APPLE_CHANGES not defined */
 	if ( res < 0 )
 	    n2 = mid - 1;
 	else if ( res > 0 )
@@ -278,7 +282,11 @@ int TextSlaveArray::findFirstMatching(Item d) const
     /* if ( !found )
 	return -1; */
     // search to first one equal or bigger
+#ifdef APPLE_CHANGES
     while ( found && (mid > 0) && !((TextSlaveArray*)this)->compareItems(d, (*this)[mid-1]) )
+#else /* APPLE_CHANGES not defined */
+    while ( found && (mid > 0) && !((QGVector*)this)->compareItems(d, (*this)[mid-1]) )
+#endif /* APPLE_CHANGES not defined */
 	mid--;
     return mid;
 }
@@ -638,8 +646,10 @@ void RenderText::printObject( QPainter *p, int /*x*/, int y, int /*w*/, int h,
 void RenderText::print( QPainter *p, int x, int y, int w, int h,
                       int tx, int ty)
 {
-    //if ( !isVisible() )
-    //    return;
+#ifndef APPLE_CHANGES
+    if ( !isVisible() )
+        return;
+#endif /* APPLE_CHANGES not defined */
 
     int s = m_lines.count() - 1;
     if ( s < 0 ) return;
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index d30f046..cf0b438 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -78,7 +78,6 @@
 using namespace DOM;
 using namespace khtml;
 
-
 //template class QStack<DOM::NodeImpl>; // needed ?
 
 
@@ -586,11 +585,14 @@ void DocumentImpl::recalcStyle()
         float dpiY = 72.; // fallback
         if ( !khtml::printpainter )
             dpiY = paintDeviceMetrics()->logicalDpiY();
+#ifdef APPLE_CHANGES
         // FIXME: Is SCREEN_RESOLUTION hack good enough?
-        //if ( !khtml::printpainter && dpiY < 96 )
-        //    dpiY = 96.;
         if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
             dpiY = SCREEN_RESOLUTION;
+#else /* APPLE_CHANGES not defined */
+        if ( !khtml::printpainter && dpiY < 96 )
+            dpiY = 96.;
+#endif /* APPLE_CHANGES not defined */
         float size = fs[3] * dpiY / 72.;
         if(size < settings->minFontSize())
             size = settings->minFontSize();
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index a297ae4..32eecd5 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -180,14 +180,13 @@ NodeImpl *NodeImpl::addChild(NodeImpl *)
   return 0;
 }
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 khtml::RenderObject *NodeImpl::renderer() const
 {
     return m_render;
 }
-#endif
-
 
+#endif /* APPLE_CHANGES */
 QString NodeImpl::toHTML() const
 {
     NodeImpl* fc = firstChild();
diff --git a/WebCore/khtml/xml/dom_nodeimpl.h b/WebCore/khtml/xml/dom_nodeimpl.h
index 8f98b0c..d3bb215 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/khtml/xml/dom_nodeimpl.h
@@ -193,11 +193,11 @@ public:
     virtual khtml::RenderStyle *style() const { return 0; }
 
     virtual void setRenderer(khtml::RenderObject *object) { m_render = object; }
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     khtml::RenderObject *renderer() const;
-#else
+#else /* APPLE_CHANGES not defined */
     virtual khtml::RenderObject *renderer() const { return m_render; }
-#endif
+#endif /* APPLE_CHANGES not defined */
 
 
     virtual DOM::CSSStyleDeclarationImpl *styleRules() { return 0; }
diff --git a/WebCore/khtml/xml/dom_stringimpl.cpp b/WebCore/khtml/xml/dom_stringimpl.cpp
index 6e39f88..55b716b 100644
--- a/WebCore/khtml/xml/dom_stringimpl.cpp
+++ b/WebCore/khtml/xml/dom_stringimpl.cpp
@@ -213,6 +213,9 @@ Length DOMStringImpl::toLength() const
 
 QList<Length> *DOMStringImpl::toLengthList() const
 {
+#ifndef APPLE_CHANGES
+    QString str(s, l);
+#endif /* APPLE_CHANGES not defined */
     int pos = 0;
     int pos2;
 
@@ -220,7 +223,7 @@ QList<Length> *DOMStringImpl::toLengthList() const
     // to fix lists like "1,2px 3 ,4"
     // make sure not to break percentage or relative widths
     // ### what about "auto" ?
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     QChar spacified[l];
     QChar space(' ');
     for(unsigned int i=0; i < l; i++) {
@@ -233,16 +236,14 @@ QList<Length> *DOMStringImpl::toLengthList() const
         }
     }
     QString str(spacified, l);
-#else
-    QString str(s, l);
+#else /* APPLE_CHANGES not defined */
     QChar space(' ');
     for(unsigned int i=0; i < l; i++) {
         char cc = str[i].latin1();
-        if ( cc > '9' || ( cc < '0' && cc != '-' && cc != '*' && cc != '%' && cc != '.') ){
+        if ( cc > '9' || ( cc < '0' && cc != '-' && cc != '*' && cc != '%' && cc != '.') )
             str[i] = space;
-        }
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
     str = str.simplifyWhiteSpace();
 
     QList<Length> *list = new QList<Length>;
diff --git a/WebCore/src/kdelibs/khtml/css/csshelper.cpp b/WebCore/src/kdelibs/khtml/css/csshelper.cpp
index 515fcfa..dce46f3 100644
--- a/WebCore/src/kdelibs/khtml/css/csshelper.cpp
+++ b/WebCore/src/kdelibs/khtml/css/csshelper.cpp
@@ -54,10 +54,14 @@ float khtml::computeLengthFloat(DOM::CSSPrimitiveValueImpl *val, RenderStyle *st
     float dpiY = 72.; // fallback
     if ( devMetrics )
         dpiY = devMetrics->logicalDpiY();
-        
+#ifdef APPLE_CHANGES
     // FIXME: SCREEN_RESOLUTION hack good enough to keep?
     if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
         dpiY = SCREEN_RESOLUTION;
+#else /* APPLE_CHANGES not defined */
+    if ( !khtml::printpainter && dpiY < 96 )
+        dpiY = 96.;
+#endif /* APPLE_CHANGES not defined */
 
     float factor = 1.;
     switch(type)
@@ -143,11 +147,13 @@ DOMString khtml::parseURL(const DOMString &url)
 
 void khtml::setFontSize( QFont &f,  int  pixelsize, const KHTMLSettings *s, QPaintDeviceMetrics *devMetrics )
 {
-    float size = pixelsize;
-
-#ifndef _KWQ_
+#ifndef APPLE_CHANGES
     QFontDatabase db;
+#endif /* APPLE_CHANGES not defined */
 
+    float size = pixelsize;
+
+#ifndef APPLE_CHANGES
     float toPix = 1.;
     if ( !khtml::printpainter )
         toPix = devMetrics->logicalDpiY()/72.;
@@ -185,7 +191,8 @@ void khtml::setFontSize( QFont &f,  int  pixelsize, const KHTMLSettings *s, QPai
 //         else if ( size > 4 && size < 16 )
 //             size = float( int( ( size + 1 ) / 2 )*2 );
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
+
     //qDebug(" -->>> using %f pixel font", size);
 
     f.setPixelSizeFloat( size );
diff --git a/WebCore/src/kdelibs/khtml/css/cssstyleselector.cpp b/WebCore/src/kdelibs/khtml/css/cssstyleselector.cpp
index 6354c50..9513da4 100644
--- a/WebCore/src/kdelibs/khtml/css/cssstyleselector.cpp
+++ b/WebCore/src/kdelibs/khtml/css/cssstyleselector.cpp
@@ -73,12 +73,11 @@ static int usedDynamicStates;
 static int selectorDynamicState;
 static CSSStyleSelector::Encodedurl *encodedurl;
 
+
 CSSStyleSelector::CSSStyleSelector(DocumentImpl * doc)
 {
     strictParsing = doc->parseMode() == DocumentImpl::Strict;
-    if(!defaultStyle){
-        loadDefaultStyle(doc->view()?doc->view()->part()->settings():0);
-    }
+    if(!defaultStyle) loadDefaultStyle(doc->view()?doc->view()->part()->settings():0);
 
     selectors = 0;
     selectorCache = 0;
@@ -1941,9 +1940,14 @@ void khtml::applyRule(khtml::RenderStyle *style, DOM::CSSProperty *prop, DOM::El
         float toPix = 1.; // fallback
         if ( !khtml::printpainter )
             toPix = paintDeviceMetrics->logicalDpiY()/72.;
+#ifdef APPLE_CHANGES
         // FIXME: SCREEN_RESOLUTION hack good enough to keep?
         if ( !khtml::printpainter && toPix < SCREEN_RESOLUTION/72 )
             toPix = SCREEN_RESOLUTION/72;
+#else /* APPLE_CHANGES not defined */
+        if ( !khtml::printpainter && toPix < 96./72. )
+            toPix = 96./72.;
+#endif /* APPLE_CHANGES not defined */
 
         QValueList<int> standardSizes = e->ownerDocument()->view()->part()->fontSizes();
         if(e->parentNode()) {
diff --git a/WebCore/src/kdelibs/khtml/dom/dom_misc.cpp b/WebCore/src/kdelibs/khtml/dom/dom_misc.cpp
index de664e1..3d6edd4 100644
--- a/WebCore/src/kdelibs/khtml/dom/dom_misc.cpp
+++ b/WebCore/src/kdelibs/khtml/dom/dom_misc.cpp
@@ -23,8 +23,9 @@
 
 #include "dom_misc.h"
 using namespace DOM;
-
+#ifdef APPLE_CHANGES
 #include <stdio.h>
+#endif /* APPLE_CHANGES */
 
 DomShared::~DomShared()
 {
@@ -38,7 +39,8 @@ bool DomShared::deleteMe()
   return false;
 }
 
-#ifdef _KWQ_
+
+#ifdef APPLE_CHANGES
 void *DomShared::instanceToCheck;
 
 void DomShared::ref()
@@ -59,4 +61,4 @@ void DomShared::deref()
     if(!_ref && deleteMe())
         delete this; 
 }
-#endif
+#endif /* APPLE_CHANGES */
diff --git a/WebCore/src/kdelibs/khtml/dom/dom_misc.h b/WebCore/src/kdelibs/khtml/dom/dom_misc.h
index 265b571..ea3f7af 100644
--- a/WebCore/src/kdelibs/khtml/dom/dom_misc.h
+++ b/WebCore/src/kdelibs/khtml/dom/dom_misc.h
@@ -32,7 +32,6 @@ namespace DOM {
  * Other objects should overload deleteMe() to fit their needs. The default
  * implementation deletes the object if the ref count drops to 0.
  */
- 
 class DomShared
 {
 public:
@@ -43,16 +42,15 @@ public:
    */
   virtual bool deleteMe();
 
-#ifndef _KWQ_
-  void ref() { _ref++; }
-  void deref() { if(_ref) _ref--; if(!_ref && deleteMe()) delete this; }
-#else
+#ifdef APPLE_CHANGES
   static void *instanceToCheck;
 
   void ref();
   void deref();
-#endif
-
+#else /* APPLE_CHANGES not defined */
+  void ref() { _ref++; }
+  void deref() { if(_ref) _ref--; if(!_ref && deleteMe()) delete this; }
+#endif /* APPLE_CHANGES not defined */
   // ###  KDE 3.0: add const
   bool hasOneRef() { return _ref == 1; }
   unsigned int refCount() const { return _ref; }
diff --git a/WebCore/src/kdelibs/khtml/dom/html_document.cpp b/WebCore/src/kdelibs/khtml/dom/html_document.cpp
index 91ab8e1..ede83ee 100644
--- a/WebCore/src/kdelibs/khtml/dom/html_document.cpp
+++ b/WebCore/src/kdelibs/khtml/dom/html_document.cpp
@@ -41,6 +41,7 @@
 #include "khtmlview.h"
 using namespace DOM;
 
+
 HTMLDocument::HTMLDocument() : Document(false) // create the impl here
 {
     impl = new HTMLDocumentImpl();
@@ -178,11 +179,11 @@ HTMLCollection HTMLDocument::all() const
 
 DOMString HTMLDocument::cookie() const
 {
+#ifdef APPLE_CHANGES
 // FIXME: implement cookies
-#ifdef _KWQ_
     fprintf(stderr, "ERROR %s:%d  %s (NOT YET IMPLEMENTED)\n", __FILE__, __LINE__, __FUNCTION__);
     return DOMString("");
-#else
+#else /* APPLE_CHANGES not defined */
     QCString replyType;
     QByteArray params, reply;
     QDataStream stream(params, IO_WriteOnly);
@@ -203,14 +204,14 @@ DOMString HTMLDocument::cookie() const
     QString result;
     stream2 >> result;
     return DOMString(result);
-#endif
+#endif /* APPLE_CHANGES not defined */
 }
 
 void HTMLDocument::setCookie( const DOMString & value )
 {
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     fprintf(stderr, "ERROR %s:%d  %s (NOT YET IMPLEMENTED)\n", __FILE__, __LINE__, __FUNCTION__);
-#else
+#else /* APPLE_CHANGES not defined */
     long windowId = view()->winId();
     QByteArray params;
     QDataStream stream(params, IO_WriteOnly);
@@ -223,7 +224,7 @@ void HTMLDocument::setCookie( const DOMString & value )
     {
 	 kdWarning(6010) << "Can't communicate with cookiejar!" << endl;
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
 }
 
 void HTMLDocument::open(  )
diff --git a/WebCore/src/kdelibs/khtml/dom/html_element.cpp b/WebCore/src/kdelibs/khtml/dom/html_element.cpp
index 1f8adcf..f5590ad 100644
--- a/WebCore/src/kdelibs/khtml/dom/html_element.cpp
+++ b/WebCore/src/kdelibs/khtml/dom/html_element.cpp
@@ -1,4 +1,4 @@
- /**
+/**
  * This file is part of the DOM implementation for KDE.
  *
  * (C) 1999 Lars Knoll (knoll at kde.org)
diff --git a/WebCore/src/kdelibs/khtml/ecma/kjs_binding.h b/WebCore/src/kdelibs/khtml/ecma/kjs_binding.h
index f426b69..a819809 100644
--- a/WebCore/src/kdelibs/khtml/ecma/kjs_binding.h
+++ b/WebCore/src/kdelibs/khtml/ecma/kjs_binding.h
@@ -26,7 +26,9 @@
 #include <dom/dom_doc.h>
 #include <kurl.h>
 #include <qguardedptr.h>
+#ifdef APPLE_CHANGES
 #include <qvariant.h>
+#endif /* APPLE_CHANGES */
 
 namespace KJS {
 
diff --git a/WebCore/src/kdelibs/khtml/ecma/kjs_css.cpp b/WebCore/src/kdelibs/khtml/ecma/kjs_css.cpp
index 32c74a5..5eae7cb 100644
--- a/WebCore/src/kdelibs/khtml/ecma/kjs_css.cpp
+++ b/WebCore/src/kdelibs/khtml/ecma/kjs_css.cpp
@@ -150,7 +150,7 @@ Completion DOMCSSStyleDeclarationFunc::tryExecute(const List &args)
   String str = args[0].toString();
   DOM::DOMString s = str.value().string();
 
-  switch (_id) {
+  switch (id) {
     case GetPropertyValue:
       result = getString(styleDecl.getPropertyValue(s));
       break;
@@ -294,7 +294,7 @@ Completion DOMStyleSheetListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  if (_id == Item)
+  if (id == Item)
     result = getDOMStyleSheet(styleSheetList.item(args[0].toNumber().intValue()));
   return Completion(ReturnValue, result);
 }
@@ -357,7 +357,7 @@ Completion DOMMediaListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case Item:
       result = getString(mediaList.item(args[0].toNumber().intValue()));
       break;
@@ -408,7 +408,7 @@ Completion DOMCSSStyleSheetFunc::tryExecute(const List &args)
   String str = args[0].toString();
   DOM::DOMString s = str.value().string();
 
-  switch (_id) {
+  switch (id) {
     case InsertRule:
       result = Number(styleSheet.insertRule(args[0].toString().value().string(),(long unsigned int)args[1].toNumber().intValue()));
       break;
@@ -452,7 +452,7 @@ Completion DOMCSSRuleListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case Item:
       result = getDOMCSSRule(cssRuleList.item(args[0].toNumber().intValue()));
       break;
@@ -586,9 +586,9 @@ Completion DOMCSSRuleFunc::tryExecute(const List &args)
 
   if (cssRule.type() == DOM::CSSRule::MEDIA_RULE) {
     DOM::CSSMediaRule rule = static_cast<DOM::CSSMediaRule>(cssRule);
-    if (_id == InsertRule)
+    if (id == InsertRule)
       result = Number(rule.insertRule(args[0].toString().value().string(),args[1].toNumber().intValue()));
-    else if (_id == DeleteRule)
+    else if (id == DeleteRule)
       rule.deleteRule(args[0].toNumber().intValue());
   }
 
@@ -773,7 +773,7 @@ Completion DOMCSSPrimitiveValueFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case SetFloatValue:
       val.setFloatValue(args[0].toNumber().intValue(),args[1].toNumber().value());
       result = Undefined();
@@ -879,7 +879,7 @@ Completion DOMCSSValueListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case Item:
       result = getDOMCSSValue(valueList.item(args[0].toNumber().intValue()));
       break;
diff --git a/WebCore/src/kdelibs/khtml/ecma/kjs_css.h b/WebCore/src/kdelibs/khtml/ecma/kjs_css.h
index b772fea..1d78212 100644
--- a/WebCore/src/kdelibs/khtml/ecma/kjs_css.h
+++ b/WebCore/src/kdelibs/khtml/ecma/kjs_css.h
@@ -28,6 +28,9 @@
 #include <dom/css_rule.h>
 #include "kjs_binding.h"
 
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#define id id_
+#endif /* APPLE_CHANGES, __OBJC__ */
 namespace KJS {
 
   class DOMCSSStyleDeclaration : public DOMObject {
@@ -46,13 +49,13 @@ namespace KJS {
   class DOMCSSStyleDeclarationFunc : public DOMFunction {
     friend class DOMNode;
   public:
-    DOMCSSStyleDeclarationFunc(DOM::CSSStyleDeclaration s, int i) : styleDecl(s), _id(i) { }
+    DOMCSSStyleDeclarationFunc(DOM::CSSStyleDeclaration s, int i) : styleDecl(s), id(i) { }
     Completion tryExecute(const List &);
     enum { GetPropertyValue, GetPropertyCSSValue, RemoveProperty, GetPropertyPriority,
            SetProperty, Item };
   private:
     DOM::CSSStyleDeclaration styleDecl;
-    int _id;
+    int id;
   };
 
   KJSO getDOMCSSStyleDeclaration(DOM::CSSStyleDeclaration n);
@@ -90,12 +93,12 @@ namespace KJS {
   class DOMStyleSheetListFunc : public DOMFunction {
     friend class DOMStyleSheetList;
   public:
-    DOMStyleSheetListFunc(DOM::StyleSheetList ssl, int i) : styleSheetList(ssl), _id(i) { }
+    DOMStyleSheetListFunc(DOM::StyleSheetList ssl, int i) : styleSheetList(ssl), id(i) { }
     Completion tryExecute(const List &);
     enum { Item };
   private:
     DOM::StyleSheetList styleSheetList;
-    int _id;
+    int id;
   };
 
   class DOMMediaList : public DOMObject {
@@ -116,12 +119,12 @@ namespace KJS {
   class DOMMediaListFunc : public DOMFunction {
     friend class DOMMediaList;
   public:
-    DOMMediaListFunc(DOM::MediaList ml, int i) : mediaList(ml), _id(i) { }
+    DOMMediaListFunc(DOM::MediaList ml, int i) : mediaList(ml), id(i) { }
     Completion tryExecute(const List &);
     enum { Item, DeleteMedium, AppendMedium };
   private:
     DOM::MediaList mediaList;
-    int _id;
+    int id;
   };
 
   class DOMCSSStyleSheet : public DOMStyleSheet {
@@ -137,12 +140,12 @@ namespace KJS {
   class DOMCSSStyleSheetFunc : public DOMFunction {
     friend class DOMNode;
   public:
-    DOMCSSStyleSheetFunc(DOM::CSSStyleSheet ss, int i) : styleSheet(ss), _id(i) { }
+    DOMCSSStyleSheetFunc(DOM::CSSStyleSheet ss, int i) : styleSheet(ss), id(i) { }
     Completion tryExecute(const List &);
     enum { InsertRule, DeleteRule };
   private:
     DOM::CSSStyleSheet styleSheet;
-    int _id;
+    int id;
   };
 
   class DOMCSSRuleList : public DOMObject {
@@ -159,12 +162,12 @@ namespace KJS {
 
   class DOMCSSRuleListFunc : public DOMFunction {
   public:
-    DOMCSSRuleListFunc(DOM::CSSRuleList rl, int i) : cssRuleList(rl), _id(i) { }
+    DOMCSSRuleListFunc(DOM::CSSRuleList rl, int i) : cssRuleList(rl), id(i) { }
     Completion tryExecute(const List &);
     enum { Item };
   private:
     DOM::CSSRuleList cssRuleList;
-    int _id;
+    int id;
   };
 
   KJSO getDOMCSSRuleList(DOM::CSSRuleList rl);
@@ -184,12 +187,12 @@ namespace KJS {
 
   class DOMCSSRuleFunc : public DOMFunction {
   public:
-    DOMCSSRuleFunc(DOM::CSSRule r, int i) : cssRule(r), _id(i) { }
+    DOMCSSRuleFunc(DOM::CSSRule r, int i) : cssRule(r), id(i) { }
     Completion tryExecute(const List &);
     enum { Item, InsertRule, DeleteRule };
   private:
     DOM::CSSRule cssRule;
-    int _id;
+    int id;
   };
 
   KJSO getDOMCSSRule(DOM::CSSRule r);
@@ -249,13 +252,13 @@ namespace KJS {
   class DOMCSSPrimitiveValueFunc : public DOMFunction {
     friend class DOMNode;
   public:
-    DOMCSSPrimitiveValueFunc(DOM::CSSPrimitiveValue v, int i) : val(v), _id(i) { }
+    DOMCSSPrimitiveValueFunc(DOM::CSSPrimitiveValue v, int i) : val(v), id(i) { }
     Completion tryExecute(const List &);
     enum { SetFloatValue, GetFloatValue, SetStringValue, GetStringValue,
            GetCounterValue, GetRectValue, GetRGBColorValue };
   private:
     DOM::CSSPrimitiveValue val;
-    int _id;
+    int id;
   };
 
   // Prototype object CSSPrimitiveValue
@@ -281,12 +284,12 @@ namespace KJS {
 
   class DOMCSSValueListFunc : public DOMFunction {
   public:
-    DOMCSSValueListFunc(DOM::CSSValueList vl, int i) : valueList(vl), _id(i) { }
+    DOMCSSValueListFunc(DOM::CSSValueList vl, int i) : valueList(vl), id(i) { }
     Completion tryExecute(const List &);
     enum { Item };
   private:
     DOM::CSSValueList valueList;
-    int _id;
+    int id;
   };
 
   class DOMRGBColor : public DOMObject {
@@ -332,5 +335,8 @@ namespace KJS {
   KJSO getDOMCounter(DOM::Counter c);
 
 }; // namespace
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#undef id
+#endif /* APPLE_CHANGES, __OBJC__ */
 
 #endif
diff --git a/WebCore/src/kdelibs/khtml/ecma/kjs_dom.cpp b/WebCore/src/kdelibs/khtml/ecma/kjs_dom.cpp
index 045e03c..bfcdbde 100644
--- a/WebCore/src/kdelibs/khtml/ecma/kjs_dom.cpp
+++ b/WebCore/src/kdelibs/khtml/ecma/kjs_dom.cpp
@@ -324,7 +324,7 @@ Completion DOMNodeFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch (_id) {
+  switch (id) {
     case HasChildNodes:
       result = Boolean(node.hasChildNodes());
       break;
@@ -411,7 +411,7 @@ Completion DOMNodeListFunc::tryExecute(const List &args)
 {
   KJSO result;
 
-  if (_id == Item)
+  if (id == Item)
     result = getDOMNode(list.item(args[0].toNumber().intValue()));
   return Completion(ReturnValue, result);
 }
@@ -528,7 +528,7 @@ KJSO DOMDocument::tryGet(const UString &p) const
 }
 
 DOMDocFunction::DOMDocFunction(DOM::Document d, int i)
-  : doc(d), _id(i)
+  : doc(d), id(i)
 {
 }
 
@@ -540,7 +540,7 @@ Completion DOMDocFunction::tryExecute(const List &args)
   String str = args[0].toString();
   DOM::DOMString s = str.value().string();
 
-  switch(_id) {
+  switch(id) {
   case CreateElement:
     result = getDOMNode(doc.createElement(s));
     break;
@@ -670,7 +670,7 @@ KJSO DOMElement::tryGet(const UString &p) const
 
 
 DOMElementFunction::DOMElementFunction(DOM::Element e, int i)
-  : element(e), _id(i)
+  : element(e), id(i)
 {
 }
 
@@ -678,7 +678,7 @@ Completion DOMElementFunction::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch(_id) {
+  switch(id) {
     case GetAttribute:
       result = String(element.getAttribute(args[0].toString().value().string()));
       break;
@@ -746,7 +746,7 @@ KJSO DOMDOMImplementation::tryGet(const UString &p) const
 }
 
 DOMDOMImplementationFunction::DOMDOMImplementationFunction(DOM::DOMImplementation impl, int i)
-  : implementation(impl), _id(i)
+  : implementation(impl), id(i)
 {
 }
 
@@ -754,7 +754,7 @@ Completion DOMDOMImplementationFunction::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch(_id) {
+  switch(id) {
     case HasFeature:
       result = Boolean(implementation.hasFeature(args[0].toString().value().string(),args[1].toString().value().string()));
       break;
@@ -836,7 +836,7 @@ KJSO DOMNamedNodeMap::tryGet(const UString &p) const
 }
 
 DOMNamedNodeMapFunction::DOMNamedNodeMapFunction(DOM::NamedNodeMap m, int i)
-  : map(m), _id(i)
+  : map(m), id(i)
 {
 }
 
@@ -844,7 +844,7 @@ Completion DOMNamedNodeMapFunction::tryExecute(const List &args)
 {
   KJSO result;
 
-  switch(_id) {
+  switch(id) {
     case GetNamedItem:
       result = getDOMNode(map.getNamedItem(args[0].toString().value().string()));
       break;
diff --git a/WebCore/src/kdelibs/khtml/ecma/kjs_dom.h b/WebCore/src/kdelibs/khtml/ecma/kjs_dom.h
index ea42e7a..f57057f 100644
--- a/WebCore/src/kdelibs/khtml/ecma/kjs_dom.h
+++ b/WebCore/src/kdelibs/khtml/ecma/kjs_dom.h
@@ -31,6 +31,9 @@
 #include "kjs_binding.h"
 #include "kjs_css.h"
 
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#define id id_
+#endif /* APPLE_CHANGES, __OBJC__ */
 namespace KJS {
 
   class DOMNode : public DOMObject {
@@ -58,14 +61,14 @@ namespace KJS {
   class DOMNodeFunc : public DOMFunction {
     friend class DOMNode;
   public:
-    DOMNodeFunc(DOM::Node n, int i) : node(n), _id(i) { }
+    DOMNodeFunc(DOM::Node n, int i) : node(n), id(i) { }
     Completion tryExecute(const List &);
     enum { InsertBefore, ReplaceChild, RemoveChild, AppendChild,
 	   HasChildNodes, CloneNode, AddEventListener, RemoveEventListener,
 	   DispatchEvent };
   private:
     DOM::Node node;
-    int _id;
+    int id;
   };
 
   class DOMNodeList : public DOMObject {
@@ -84,12 +87,12 @@ namespace KJS {
   class DOMNodeListFunc : public DOMFunction {
     friend class DOMNodeList;
   public:
-    DOMNodeListFunc(DOM::NodeList l, int i) : list(l), _id(i) { }
+    DOMNodeListFunc(DOM::NodeList l, int i) : list(l), id(i) { }
     Completion tryExecute(const List &);
     enum { Item };
   private:
     DOM::NodeList list;
-    int _id;
+    int id;
   };
 
   class DOMDocument : public DOMNode {
@@ -112,7 +115,7 @@ namespace KJS {
 	   CreateRange, CreateNodeIterator, CreateTreeWalker, CreateEvent, GetOverrideStyle };
   private:
     DOM::Document doc;
-    int _id;
+    int id;
   };
 
   class DOMAttr : public DOMNode {
@@ -144,7 +147,7 @@ namespace KJS {
            Normalize };
   private:
     DOM::Element element;
-    int _id;
+    int id;
   };
 
   class DOMDOMImplementation : public DOMObject {
@@ -167,7 +170,7 @@ namespace KJS {
     enum { HasFeature, CreateDocumentType, CreateDocument, CreateCSSStyleSheet };
   private:
     DOM::DOMImplementation implementation;
-    int _id;
+    int id;
   };
 
   class DOMDocumentType : public DOMNode {
@@ -200,7 +203,7 @@ namespace KJS {
            GetNamedItemNS, SetNamedItemNS, RemoveNamedItemNS };
   private:
     DOM::NamedNodeMap map;
-    int _id;
+    int id;
   };
 
   class DOMProcessingInstruction : public DOMNode {
@@ -258,5 +261,8 @@ namespace KJS {
   KJSO getDOMExceptionPrototype();
 
 }; // namespace
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#undef id
+#endif /* APPLE_CHANGES, __OBJC__ */
 
 #endif
diff --git a/WebCore/src/kdelibs/khtml/ecma/kjs_window.cpp b/WebCore/src/kdelibs/khtml/ecma/kjs_window.cpp
index 04d77dd..50ee5b3 100644
--- a/WebCore/src/kdelibs/khtml/ecma/kjs_window.cpp
+++ b/WebCore/src/kdelibs/khtml/ecma/kjs_window.cpp
@@ -798,7 +798,6 @@ bool Window::isSafeScript() const
   KHTMLPart *act = (KHTMLPart*)KJS::Global::current().extra();
   if (!act)
       kdDebug(6070) << "Window::isSafeScript: KJS::Global::current().extra() is 0L!" << endl;
-  
   return act && originCheck(m_part->url(), act->url());
 }
 
diff --git a/WebCore/src/kdelibs/khtml/html/html_formimpl.cpp b/WebCore/src/kdelibs/khtml/html/html_formimpl.cpp
index cae01fb..edae300 100644
--- a/WebCore/src/kdelibs/khtml/html/html_formimpl.cpp
+++ b/WebCore/src/kdelibs/khtml/html/html_formimpl.cpp
@@ -180,7 +180,7 @@ QByteArray HTMLFormElementImpl::formData()
     QCString enc_string = ""; // used for non-multipart data
 
     // find out the QTextcodec to use
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     QString origStr = m_acceptcharset.string();
     QChar space(' ');
     QChar strChars[origStr.length()];
@@ -191,15 +191,11 @@ QByteArray HTMLFormElementImpl::formData()
         else
             strChars[i] = origStr[i];
     QString str(strChars, origStr.length());
-#else
+#else /* APPLE_CHANGES not defined */
     QString str = m_acceptcharset.string();
     QChar space(' ');
-
-    for(unsigned int i=0; i < str.length(); i++)
-        if(str[i].latin1() == ',')
-            str[i] = space;
-#endif
-
+    for(unsigned int i=0; i < str.length(); i++) if(str[i].latin1() == ',') str[i] = space;
+#endif /* APPLE_CHANGES not defined */
     QStringList charsets = QStringList::split(' ', str);
     QTextCodec* codec = 0;
     for ( QStringList::Iterator it = charsets.begin(); it != charsets.end(); ++it )
@@ -225,17 +221,17 @@ QByteArray HTMLFormElementImpl::formData()
     if(!codec)
         codec = QTextCodec::codecForLocale();
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     QString encCharset = codec->name();
     QChar encChars[encCharset.length()];
     for(unsigned int i=0; i < encCharset.length(); i++)
         encChars[i] = encCharset[i].latin1() == ' ' ? QChar('-') : encCharset[i].lower();
     QString m_encCharset(encChars,  encCharset.length());
-#else
+#else /* APPLE_CHANGES not defined */
     m_encCharset = codec->name();
     for(unsigned int i=0; i < m_encCharset.length(); i++)
         m_encCharset[i] = m_encCharset[i].latin1() == ' ' ? QChar('-') : m_encCharset[i].lower();
-#endif
+#endif /* APPLE_CHANGES not defined */
 
     for(HTMLGenericFormElementImpl *current = formElements.first(); current; current = formElements.next())
     {
@@ -1509,18 +1505,14 @@ void HTMLSelectElementImpl::setValue(DOMStringImpl* /*value*/)
 
 QString HTMLSelectElementImpl::state( )
 {
+#ifndef APPLE_CHANGES
+    QString state;
+#endif /* APPLE_CHANGES not defined */
     QArray<HTMLGenericFormElementImpl*> items = listItems();
 
     int l = items.count();
 
-#ifndef _KWQ_
-    QString state;
-
-    state.fill('.', l);
-    for(int i = 0; i < l; i++)
-        if(items[i]->id() == ID_OPTION && static_cast<HTMLOptionElementImpl*>(items[i])->selected())
-            state[i] = 'X';
-#else
+#ifdef APPLE_CHANGES
     QChar stateChars[l];
     
     for(int i = 0; i < l; i++)
@@ -1529,7 +1521,12 @@ QString HTMLSelectElementImpl::state( )
         else
             stateChars[i] = '.';
     QString state(stateChars, l);
-#endif
+#else /* APPLE_CHANGES not defined */
+    state.fill('.', l);
+    for(int i = 0; i < l; i++)
+        if(items[i]->id() == ID_OPTION && static_cast<HTMLOptionElementImpl*>(items[i])->selected())
+            state[i] = 'X';
+#endif /* APPLE_CHANGES not defined */
 
     return state;
 }
@@ -1541,13 +1538,13 @@ void HTMLSelectElementImpl::restoreState(const QString &_state)
     QString state = _state;
     if(!state.isEmpty() && !state.contains('X') && !m_multiple) {
         ASSERT("should not happen in restoreState!");
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
         // Invalid access to string's internal buffer.  Should never get here
         // anyway.
         //state[0] = 'X';
-#else
+#else /* APPLE_CHANGES not defined */
         state[0] = 'X';
-#endif
+#endif /* APPLE_CHANGES not defined */
     }
 
     QArray<HTMLGenericFormElementImpl*> items = listItems();
diff --git a/WebCore/src/kdelibs/khtml/html/html_headimpl.cpp b/WebCore/src/kdelibs/khtml/html/html_headimpl.cpp
index 599d2fc..925d285 100644
--- a/WebCore/src/kdelibs/khtml/html/html_headimpl.cpp
+++ b/WebCore/src/kdelibs/khtml/html/html_headimpl.cpp
@@ -148,9 +148,14 @@ void HTMLLinkElementImpl::attach()
 
 void HTMLLinkElementImpl::detach()
 {
+#ifdef APPLE_CHANGES
     // RJW:  Why is this done here?
     //if ( sheet() )
     //    getDocument()->createSelector();
+#else /* APPLE_CHANGES not defined */
+    if ( sheet() )
+        getDocument()->createSelector();
+#endif /* APPLE_CHANGES not defined */
 
     HTMLElementImpl::detach();
 }
@@ -432,9 +437,12 @@ void HTMLStyleElementImpl::attach()
 
 void HTMLStyleElementImpl::detach()
 {
+#ifdef APPLE_CHANGES
     // RJW:  Why is this done?
-    //if (m_sheet)
-    //    getDocument()->createSelector();
+    //if (m_sheet) getDocument()->createSelector();
+#else /* APPLE_CHANGES not defined */
+    if (m_sheet) getDocument()->createSelector();
+#endif /* APPLE_CHANGES not defined */
     HTMLElementImpl::detach();
 }
 
@@ -467,8 +475,14 @@ void HTMLTitleElementImpl::setTitle()
     s.compose();
     s = KStringHandler::csqueeze( s.visual(), 128 );
 
+#ifdef APPLE_CHANGES
     // FIXME: need to uncomment this eventually
     //HTMLDocumentImpl *d = static_cast<HTMLDocumentImpl *>(ownerDocument());
     //if ( !d->view()->part()->parentPart() )
     //    emit d->view()->part()->setWindowCaption( s.visual() );
+#else /* APPLE_CHANGES not defined */
+    HTMLDocumentImpl *d = static_cast<HTMLDocumentImpl *>(ownerDocument());
+    if ( !d->view()->part()->parentPart() )
+        emit d->view()->part()->setWindowCaption( s.visual() );
+#endif /* APPLE_CHANGES not defined */
 }
diff --git a/WebCore/src/kdelibs/khtml/html/html_objectimpl.cpp b/WebCore/src/kdelibs/khtml/html/html_objectimpl.cpp
index 37becc9..7b04db8 100644
--- a/WebCore/src/kdelibs/khtml/html/html_objectimpl.cpp
+++ b/WebCore/src/kdelibs/khtml/html/html_objectimpl.cpp
@@ -188,13 +188,13 @@ void HTMLEmbedElementImpl::parseAttribute(AttrImpl *attr)
   QString val = QConstString( stringImpl->s, stringImpl->l ).string();
 
   // export parameter
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     // Need to make a deep copy here or "+" operator will attempt to modify
     // QConstString attribute name
   QString attrStr = attr->name().string().copy() + "=\"" + val + "\"";
-#else
+#else /* APPLE_CHANGES not defined */
   QString attrStr = attr->name().string() + "=\"" + val + "\"";
-#endif
+#endif /* APPLE_CHANGES not defined */
   param.append( attrStr );
   int pos;
   switch ( attr->attrId )
@@ -207,11 +207,11 @@ void HTMLEmbedElementImpl::parseAttribute(AttrImpl *attr)
         break;
      case ATTR_CODE:
      case ATTR_SRC:
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
          url = khtml::parseURL(attr->val()).string().copy();
-#else
+#else /* APPLE_CHANGES not defined */
          url = khtml::parseURL(attr->val()).string();
-#endif
+#endif /* APPLE_CHANGES not defined */
          break;
      case ATTR_WIDTH:
         addCSSLength( CSS_PROP_WIDTH, attr->value() );
diff --git a/WebCore/src/kdelibs/khtml/html/html_tableimpl.cpp b/WebCore/src/kdelibs/khtml/html/html_tableimpl.cpp
index 1873ef2..2e91853 100644
--- a/WebCore/src/kdelibs/khtml/html/html_tableimpl.cpp
+++ b/WebCore/src/kdelibs/khtml/html/html_tableimpl.cpp
@@ -313,18 +313,15 @@ void HTMLTableElementImpl::parseAttribute(AttrImpl *attr)
     {
         if (!attr->value().isEmpty()) {
             HTMLDocumentImpl *doc = static_cast<HTMLDocumentImpl *>(ownerDocument());
-                        
-#ifdef _KWQ_            
+#ifdef APPLE_CHANGES
             // our c++ implementation likes this better
             DOMString d(khtml::parseURL(attr->value()));
             QString url = d.string();
-#else            
+#else /* APPLE_CHANGES not defined */
             QString url = khtml::parseURL( attr->value() ).string();
-#endif
-            
+#endif /* APPLE_CHANGES not defined */
             if ( doc->view() )
                 url = doc->view()->part()->completeURL( url ).url();
-                
             addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, "url('"+url+"')" );
         }
         else
@@ -437,17 +434,15 @@ void HTMLTablePartElementImpl::parseAttribute(AttrImpl *attr)
     {
         if (attr->val()) {
             HTMLDocumentImpl *doc = static_cast<HTMLDocumentImpl *>(ownerDocument());
-
-#ifdef _KWQ_            
+#ifdef APPLE_CHANGES
             // our c++ implementation likes this better
             DOMString d(khtml::parseURL(attr->value()));
             QString url = d.string();
-#else            
+#else /* APPLE_CHANGES not defined */
             QString url = khtml::parseURL( attr->value() ).string();
-#endif
+#endif /* APPLE_CHANGES not defined */
             if ( doc->view() )
                 url = doc->view()->part()->completeURL( url ).url();
-                
             addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, "url('"+url+"')" );
         }
         else
diff --git a/WebCore/src/kdelibs/khtml/html/htmlparser.cpp b/WebCore/src/kdelibs/khtml/html/htmlparser.cpp
index d59106d..47342aa 100644
--- a/WebCore/src/kdelibs/khtml/html/htmlparser.cpp
+++ b/WebCore/src/kdelibs/khtml/html/htmlparser.cpp
@@ -72,13 +72,13 @@ public:
                    HTMLStackElem * _next
         )
         :
-        _id(_id),
+        id(_id),
         level(_level),
         node(_node),
         next(_next)
         { }
 
-    int       _id;
+    int       id;
     int       level;
     NodeImpl *node;
     HTMLStackElem *next;
@@ -185,39 +185,39 @@ void KHTMLParser::reset()
 
 void KHTMLParser::parseToken(Token *t)
 {
-    if (t->_id > 2*ID_CLOSE_TAG)
+    if (t->id > 2*ID_CLOSE_TAG)
     {
-      kdDebug( 6035 ) << "Unknown tag!! tagID = " << t->_id << endl;
+      kdDebug( 6035 ) << "Unknown tag!! tagID = " << t->id << endl;
       return;
     }
     if(discard_until) {
-        if(t->_id == discard_until)
+        if(t->id == discard_until)
             discard_until = 0;
 
         // do not skip </iframe>
-        if ( discard_until || current->id() + ID_CLOSE_TAG != t->_id )
+        if ( discard_until || current->id() + ID_CLOSE_TAG != t->id )
             return;
     }
 
 #ifdef PARSER_DEBUG
-    kdDebug( 6035 ) << "\n\n==> parser: processing token " << getTagName(t->_id).string() << "(" << t->_id << ")"
+    kdDebug( 6035 ) << "\n\n==> parser: processing token " << getTagName(t->id).string() << "(" << t->id << ")"
                     << " current = " << getTagName(current->id()).string() << "(" << current->id() << ")" << endl;
     kdDebug(6035) << "inline=" << _inline << " inBody=" << inBody << " noRealBody=" << noRealBody << " haveFrameSet=" << haveFrameSet << endl;
 #endif
 
     // holy shit. apparently some sites use </br> instead of <br>
     // be compatible with IE and NS
-    if(t->_id == ID_BR+ID_CLOSE_TAG && document->document()->parseMode() != DocumentImpl::Strict)
-        t->_id -= ID_CLOSE_TAG;
+    if(t->id == ID_BR+ID_CLOSE_TAG && document->document()->parseMode() != DocumentImpl::Strict)
+        t->id -= ID_CLOSE_TAG;
 
-    if(t->_id > ID_CLOSE_TAG)
+    if(t->id > ID_CLOSE_TAG)
     {
         processCloseTag(t);
         return;
     }
 
     // ignore spaces, if we're not inside a paragraph or other inline code
-    if( t->_id == ID_TEXT ) {
+    if( t->id == ID_TEXT ) {
 #ifdef PARSER_DEBUG
         if(t->text)
             kdDebug(6035) << "length="<< t->text->l << " text='" << QConstString(t->text->s, t->text->l).string() << "'" << endl;
@@ -239,12 +239,12 @@ void KHTMLParser::parseToken(Token *t)
 
         // take care of optional close tags
         if(endTag[e->id()] == DOM::OPTIONAL)
-            popBlock(t->_id);
+            popBlock(t->id);
     }
 
     // if this tag is forbidden inside the current context, pop
     // blocks until we are allowed to add it...
-    while(forbiddenTag[t->_id]) popOneBlock();
+    while(forbiddenTag[t->id]) popOneBlock();
 
     if ( !insertNode(n) ) {
         // we couldn't insert the node...
@@ -271,7 +271,7 @@ void KHTMLParser::parseToken(Token *t)
 
 bool KHTMLParser::insertNode(NodeImpl *n)
 {
-    int _id = n->id();
+    int id = n->id();
 
     // let's be stupid and just try to insert it.
     // this should work if the document is wellformed
@@ -284,9 +284,9 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         kdDebug( 6035 ) << "added " << n->nodeName().string() << " to " << tmp->nodeName().string() << ", new current=" << newNode->nodeName().string() << endl;
 #endif
         // don't push elements without end tag on the stack
-        if(tagPriority[_id] != 0 && !flat)
+        if(tagPriority[id] != 0 && !flat)
         {
-            pushBlock(_id, tagPriority[_id]);
+            pushBlock(id, tagPriority[id]);
             current = newNode;
 #if SPEED_DEBUG < 2
             if(!n->attached() && HTMLWidget )  n->attach();
@@ -303,7 +303,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         }
 
 #if SPEED_DEBUG < 1
-        if(tagPriority[_id] == 0 && n->renderer())
+        if(tagPriority[id] == 0 && n->renderer())
             n->renderer()->calcMinMaxWidth();
 #endif
         return true;
@@ -316,7 +316,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         bool handled = false;
 
         // switch according to the element to insert
-        switch(_id)
+        switch(id)
         {
         case ID_COMMENT:
             break;
@@ -351,7 +351,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
             if ( head ) {
                 DOM::NodeImpl *newNode = head->addChild(n);
                 if ( newNode ) {
-                    pushBlock(_id, tagPriority[_id]);
+                    pushBlock(id, tagPriority[id]);
                     current = newNode;
 #if SPEED_DEBUG < 2
                     if(!n->attached() && HTMLWidget)
@@ -455,7 +455,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         switch(current->id())
         {
         case ID_HTML:
-            switch(_id)
+            switch(id)
             {
             case ID_SCRIPT:
             case ID_STYLE:
@@ -493,7 +493,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
             break;
         case ID_HEAD:
             // we can get here only if the element is not allowed in head.
-            if (_id == ID_HTML)
+            if (id == ID_HTML)
                 return false;
             else {
                 // This means the body starts here...
@@ -508,7 +508,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         case ID_BODY:
             break;
         case ID__KONQBLOCK:
-            switch( _id ) {
+            switch( id ) {
             case ID_THEAD:
             case ID_TFOOT:
             case ID_TBODY:
@@ -520,7 +520,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
                 // and go ahead!
                 popBlock( ID__KONQBLOCK );
                 haveKonqBlock = false;
-                handled = checkChild( current->id(), _id );
+                handled = checkChild( current->id(), id );
                 break;
             default:
                 break;
@@ -531,7 +531,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
         case ID_TFOOT:
         case ID_TBODY:
         case ID_TR:
-            switch(_id)
+            switch(id)
             {
             case ID_TABLE:
                 popBlock(ID_TABLE); // end the table
@@ -558,7 +558,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
                    ( parent->id() == ID_THEAD ||
                      parent->id() == ID_TBODY ||
                      parent->id() == ID_TFOOT ) && parentparent->id() == ID_TABLE ) ||
-                   ( !checkChild( ID_TR, _id ) && ( node->id() == ID_THEAD || node->id() == ID_TBODY || node->id() == ID_TFOOT ) &&
+                   ( !checkChild( ID_TR, id ) && ( node->id() == ID_THEAD || node->id() == ID_TBODY || node->id() == ID_TFOOT ) &&
                      parent->id() == ID_TABLE ) )
                 {
                     node = ( node->id() == ID_TR ) ? parentparent : parent;
@@ -594,7 +594,7 @@ bool KHTMLParser::insertNode(NodeImpl *n)
             } // end switch
             break;
         case ID_OBJECT:
-            discard_until = _id + ID_CLOSE_TAG;
+            discard_until = id + ID_CLOSE_TAG;
             return false;
         case ID_UL:
         case ID_OL:
@@ -631,12 +631,12 @@ bool KHTMLParser::insertNode(NodeImpl *n)
             }
             break;
         case ID_OPTION:
-            if (_id == ID_OPTGROUP)
+            if (id == ID_OPTGROUP)
             {
                 popBlock(ID_OPTION);
                 handled = true;
             }
-            else if(_id == ID_SELECT)
+            else if(id == ID_SELECT)
             {
                 // IE treats a nested select as </select>. Let's do the same
                 popBlock( ID_SELECT );
@@ -689,7 +689,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
 {
     NodeImpl *n = 0;
 
-    switch(t->_id)
+    switch(t->id)
     {
     case ID_HTML:
         n = new HTMLHtmlElementImpl(document);
@@ -800,12 +800,12 @@ NodeImpl *KHTMLParser::getElement(Token* t)
         n = new HTMLDListElementImpl(document);
         break;
     case ID_DD:
-        n = new HTMLGenericElementImpl(document, t->_id);
+        n = new HTMLGenericElementImpl(document, t->id);
         popBlock(ID_DT);
         popBlock(ID_DD);
         break;
     case ID_DT:
-        n = new HTMLGenericElementImpl(document, t->_id);
+        n = new HTMLGenericElementImpl(document, t->id);
         popBlock(ID_DD);
         popBlock(ID_DT);
         break;
@@ -850,7 +850,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
     case ID_H4:
     case ID_H5:
     case ID_H6:
-        n = new HTMLHeadingElementImpl(document, t->_id);
+        n = new HTMLHeadingElementImpl(document, t->id);
         break;
     case ID_HR:
         n = new HTMLHRElementImpl(document);
@@ -874,7 +874,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
 // ins/del
     case ID_DEL:
     case ID_INS:
-        n = new HTMLModElementImpl(document, t->_id);
+        n = new HTMLModElementImpl(document, t->id);
         break;
 
 // anchor
@@ -920,7 +920,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
         break;
     case ID_COLGROUP:
     case ID_COL:
-        n = new HTMLTableColElementImpl(document, t->_id);
+        n = new HTMLTableColElementImpl(document, t->id);
         break;
     case ID_TR:
         popBlock(ID_TR);
@@ -930,7 +930,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
     case ID_TH:
         popBlock(ID_TH);
         popBlock(ID_TD);
-        n = new HTMLTableCellElementImpl(document, t->_id);
+        n = new HTMLTableCellElementImpl(document, t->id);
         break;
     case ID_TBODY:
     case ID_THEAD:
@@ -938,7 +938,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
         popBlock( ID_THEAD );
         popBlock( ID_TBODY );
         popBlock( ID_TFOOT );
-        n = new HTMLTableSectionElementImpl(document, t->_id);
+        n = new HTMLTableSectionElementImpl(document, t->id);
         break;
 
 // inline elements
@@ -955,7 +955,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
     case ID_ADDRESS:
     case ID_CENTER:
     case ID_LISTING:
-        n = new HTMLGenericElementImpl(document, t->_id);
+        n = new HTMLGenericElementImpl(document, t->id);
         break;
 // inline
         // %fontstyle
@@ -984,7 +984,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
     case ID_SUB:
     case ID_SUP:
     case ID_SPAN:
-        n = new HTMLGenericElementImpl(document, t->_id);
+        n = new HTMLGenericElementImpl(document, t->id);
         break;
 
     case ID_BDO:
@@ -1017,7 +1017,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
 #endif
         break;
     default:
-        kdDebug( 6035 ) << "Unknown tag " << t->_id << "!" << endl;
+        kdDebug( 6035 ) << "Unknown tag " << t->id << "!" << endl;
     }
     return n;
 }
@@ -1025,7 +1025,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
 void KHTMLParser::processCloseTag(Token *t)
 {
     // support for really broken html. Can't believe I'm supporting such crap (lars)
-    switch(t->_id)
+    switch(t->id)
     {
     case ID_HTML+ID_CLOSE_TAG:
     case ID_BODY+ID_CLOSE_TAG:
@@ -1064,7 +1064,7 @@ void KHTMLParser::processCloseTag(Token *t)
         child = child->nextSibling();
     }
 #endif
-    popBlock(t->_id-ID_CLOSE_TAG);
+    popBlock(t->id-ID_CLOSE_TAG);
 #ifdef PARSER_DEBUG
     kdDebug( 6035 ) << "closeTag --> current = " << current->nodeName().string() << endl;
 #endif
@@ -1087,13 +1087,13 @@ void KHTMLParser::popBlock( int _id )
 #ifdef PARSER_DEBUG
     kdDebug( 6035 ) << "popBlock(" << getTagName(_id).string() << ")" << endl;
     while(Elem) {
-        kdDebug( 6035) << "   > " << getTagName(Elem->_id).string() << endl;
+        kdDebug( 6035) << "   > " << getTagName(Elem->id).string() << endl;
         Elem = Elem->next;
     }
     Elem = blockStack;
 #endif
 
-    while( Elem && (Elem->_id != _id))
+    while( Elem && (Elem->id != _id))
     {
         if (maxLevel < Elem->level)
         {
@@ -1108,7 +1108,7 @@ void KHTMLParser::popBlock( int _id )
 
     while (Elem)
     {
-        if (Elem->_id == _id)
+        if (Elem->id == _id)
         {
             popOneBlock();
             Elem = 0;
@@ -1129,7 +1129,7 @@ void KHTMLParser::popOneBlock()
 #ifndef PARSER_DEBUG
     if(!Elem) return;
 #else
-    kdDebug( 6035 ) << "popping block: " << getTagName(Elem->_id).string() << "(" << Elem->_id << ")" << endl;
+    kdDebug( 6035 ) << "popping block: " << getTagName(Elem->id).string() << "(" << Elem->id << ")" << endl;
 #endif
 
 #if SPEED_DEBUG < 1
@@ -1137,7 +1137,7 @@ void KHTMLParser::popOneBlock()
         if(current->renderer()) current->renderer()->close();
 #endif
 
-    removeForbidden(Elem->_id, forbiddenTag);
+    removeForbidden(Elem->id, forbiddenTag);
 
     blockStack = Elem->next;
     // we only set inline to false, if the element we close is a block level element.
diff --git a/WebCore/src/kdelibs/khtml/html/htmltokenizer.cpp b/WebCore/src/kdelibs/khtml/html/htmltokenizer.cpp
index 694c83c..cb93849 100644
--- a/WebCore/src/kdelibs/khtml/html/htmltokenizer.cpp
+++ b/WebCore/src/kdelibs/khtml/html/htmltokenizer.cpp
@@ -296,9 +296,9 @@ void HTMLTokenizer::parseSpecial(DOMStringIt &src, bool begin)
                 scriptHandler();
             else {
                 processListing(DOMStringIt(scriptCode, scriptCodeSize));
-                if ( style )         { currToken._id = ID_STYLE + ID_CLOSE_TAG; }
-                else if ( textarea ) { currToken._id = ID_TEXTAREA + ID_CLOSE_TAG; }
-                else if ( listing )  { currToken._id = ID_LISTING + ID_CLOSE_TAG; }
+                if ( style )         { currToken.id = ID_STYLE + ID_CLOSE_TAG; }
+                else if ( textarea ) { currToken.id = ID_TEXTAREA + ID_CLOSE_TAG; }
+                else if ( listing )  { currToken.id = ID_LISTING + ID_CLOSE_TAG; }
                 processToken();
                 style = script = style = textarea = listing = false;
                 scriptCodeSize = scriptCodeResync = 0;
@@ -354,7 +354,7 @@ void HTMLTokenizer::scriptHandler()
         doScriptExec = true;
     }
     processListing(DOMStringIt(scriptCode, scriptCodeSize));
-    currToken._id = ID_SCRIPT + ID_CLOSE_TAG;
+    currToken.id = ID_SCRIPT + ID_CLOSE_TAG;
     processToken();
 
     QString prependingSrc;
@@ -416,10 +416,10 @@ void HTMLTokenizer::parseComment(DOMStringIt &src)
                 checkScriptBuffer();
                 scriptCode[ scriptCodeSize ] = 0;
                 scriptCode[ scriptCodeSize + 1 ] = 0;
-                currToken._id = ID_COMMENT;
+                currToken.id = ID_COMMENT;
                 processListing(DOMStringIt(scriptCode, scriptCodeSize - 2));
                 processToken();
-                currToken._id = ID_COMMENT + ID_CLOSE_TAG;
+                currToken.id = ID_COMMENT + ID_CLOSE_TAG;
                 processToken();
 #endif
                 scriptCodeSize = 0;
@@ -743,7 +743,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
                     QCString tmp(ptr, len+1);
                     kdDebug( 6036 ) << "found tag id=" << tagID << ": " << tmp.data() << endl;
 #endif
-                    currToken._id = beginTag ? tagID : tagID + ID_CLOSE_TAG;
+                    currToken.id = beginTag ? tagID : tagID + ID_CLOSE_TAG;
                     dest = buffer;
                 }
                 tag = SearchAttribute;
@@ -1000,10 +1000,10 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
             tquote = NoQuote;
             ++src;
 
-            if ( !currToken._id ) //stop if tag is unknown
+            if ( !currToken.id ) //stop if tag is unknown
                 return;
 
-            uint tagID = currToken._id;
+            uint tagID = currToken.id;
 #if defined(TOKEN_DEBUG) && TOKEN_DEBUG > 0
             kdDebug( 6036 ) << "appending Tag: " << tagID << endl;
 #endif
@@ -1444,8 +1444,8 @@ void HTMLTokenizer::processToken()
     if ( dest > buffer )
     {
 #ifdef TOKEN_DEBUG
-        if(currToken._id && currToken._id != ID_COMMENT) {
-            qDebug( "unexpected token id: %d, str: *%s*", currToken._id,QConstString( buffer,dest-buffer ).string().latin1() );
+        if(currToken.id && currToken.id != ID_COMMENT) {
+            qDebug( "unexpected token id: %d, str: *%s*", currToken.id,QConstString( buffer,dest-buffer ).string().latin1() );
             assert(0);
         }
 
@@ -1461,10 +1461,10 @@ void HTMLTokenizer::processToken()
             currToken.text = new DOMStringImpl( buffer, dest - buffer );
             currToken.text->ref();
         }
-        if (currToken._id != ID_COMMENT)
-            currToken._id = ID_TEXT;
+        if (currToken.id != ID_COMMENT)
+            currToken.id = ID_TEXT;
     }
-    else if(!currToken._id) {
+    else if(!currToken.id) {
         currToken.reset();
         return;
     }
@@ -1472,12 +1472,12 @@ void HTMLTokenizer::processToken()
     dest = buffer;
 
 #ifdef TOKEN_DEBUG
-    QString name = getTagName(currToken._id).string();
+    QString name = getTagName(currToken.id).string();
     QString text;
     if(currToken.text)
         text = QConstString(currToken.text->s, currToken.text->l).string();
 
-    kdDebug( 6036 ) << "Token --> " << name << "   id = " << currToken._id << endl;
+    kdDebug( 6036 ) << "Token --> " << name << "   id = " << currToken.id << endl;
     if(!text.isNull())
         kdDebug( 6036 ) << "text: \"" << text << "\"" << endl;
     int l = currToken.attrs ? currToken.attrs->length() : 0;
diff --git a/WebCore/src/kdelibs/khtml/html/htmltokenizer.h b/WebCore/src/kdelibs/khtml/html/htmltokenizer.h
index 9fdfe40..62a5e37 100644
--- a/WebCore/src/kdelibs/khtml/html/htmltokenizer.h
+++ b/WebCore/src/kdelibs/khtml/html/htmltokenizer.h
@@ -54,6 +54,9 @@ class HTMLTokenizer;
 #include "misc/htmltags.h"
 #include "xml/dom_stringimpl.h"
 
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#define id id_
+#endif /* APPLE_CHANGES, __OBJC__ */
 class KHTMLParser;
 class KHTMLView;
 
@@ -76,7 +79,7 @@ namespace khtml {
     {
     public:
         Token() {
-            _id = 0;
+            id = 0;
             complexText = false;
             attrs = 0;
             text = 0;
@@ -100,7 +103,7 @@ namespace khtml {
                 attrs->deref();
                 attrs = 0;
             }
-            _id = 0;
+            id = 0;
             complexText = false;
             if(text) {
                 text->deref();
@@ -108,7 +111,7 @@ namespace khtml {
             }
         }
         DOM::NamedAttrMapImpl* attrs;
-        ushort _id;
+        ushort id;
         DOMStringImpl* text;
         bool complexText;
     };
@@ -133,8 +136,12 @@ public:
     virtual void setOnHold(bool /*_onHold*/) {}
 
 signals:
+#ifdef APPLE_CHANGES
     // temporary implementation here to get test to link
     void finishedParsing() {};
+#else /* APPLE_CHANGES not defined */
+    void finishedParsing();
+#endif /* APPLE_CHANGES not defined */
 
 };
 
@@ -357,6 +364,9 @@ protected:
 
     KHTMLView *view;
 };
+#if defined(APPLE_CHANGES) && defined(__OBJC__)
+#undef id
+#endif /* APPLE_CHANGES, __OBJC__ */
 
 #endif // HTMLTOKENIZER
 
diff --git a/WebCore/src/kdelibs/khtml/java/kjavaprocess.h b/WebCore/src/kdelibs/khtml/java/kjavaprocess.h
index fc113ff..7b18ec2 100644
--- a/WebCore/src/kdelibs/khtml/java/kjavaprocess.h
+++ b/WebCore/src/kdelibs/khtml/java/kjavaprocess.h
@@ -26,7 +26,9 @@
 
 #include <kprocess.h>
 #include <qcstring.h>
+#ifdef APPLE_CHANGES
 #include <qlist.h>
+#endif /* APPLE_CHANGES */
 
 /**
  * @short A class for invoking a Java VM
diff --git a/WebCore/src/kdelibs/khtml/khtml_part.h b/WebCore/src/kdelibs/khtml/khtml_part.h
index a94704d..e7c26a0 100644
--- a/WebCore/src/kdelibs/khtml/khtml_part.h
+++ b/WebCore/src/kdelibs/khtml/khtml_part.h
@@ -21,10 +21,9 @@
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-#ifndef ORIGINAL_KHTMLPART_HEADER
+#ifdef APPLE_CHANGES
 #include "../../kwq/KWQKHTMLPart.h"
-#else 
-
+#else /* APPLE_CHANGES not defined */
 #ifndef __khtml_part_h__
 #define __khtml_part_h__
 
@@ -1049,5 +1048,4 @@ private:
 
 
 #endif
-
-#endif
+#endif /* APPLE_CHANGES not defined */
diff --git a/WebCore/src/kdelibs/khtml/khtmlview.cpp b/WebCore/src/kdelibs/khtml/khtmlview.cpp
index 4fcfdb7..350dbb9 100644
--- a/WebCore/src/kdelibs/khtml/khtmlview.cpp
+++ b/WebCore/src/kdelibs/khtml/khtmlview.cpp
@@ -71,12 +71,20 @@ public:
     {
         underMouse = 0;
         reset();
+#ifndef APPLE_CHANGES
+        tp=0;
+        paintBuffer=0;
+#endif /* APPLE_CHANGES not defined */
         formCompletions=0;
         prevScrollbarVisible = true;
     }
     ~KHTMLViewPrivate()
     {
         delete formCompletions;
+#ifndef APPLE_CHANGES
+        delete tp; tp = 0;
+        delete paintBuffer; paintBuffer =0;
+#endif /* APPLE_CHANGES not defined */
         if (underMouse)
 	    underMouse->deref();
     }
@@ -106,8 +114,12 @@ public:
 	isDoubleClick = false;
     }
 
+#ifdef APPLE_CHANGES
     // The paintBuffer ivar is obsolete, 
     // and should probably be removed at some point
+#else /* APPLE_CHANGES not defined */
+    QPainter *tp;
+#endif /* APPLE_CHANGES not defined */
     QPixmap  *paintBuffer;
     NodeImpl *underMouse;
 
@@ -143,10 +155,9 @@ public:
         m_viewprivate = vp;
     };
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     virtual ~KHTMLToolTip() {}
-#endif
-
+#endif /* APPLE_CHANGES */
 protected:
     virtual void maybeTip(const QPoint &);
 
@@ -200,6 +211,16 @@ KHTMLView::KHTMLView( KHTMLPart *part, QWidget *parent, const char *name)
 
 KHTMLView::~KHTMLView()
 {
+#ifndef APPLE_CHANGES
+    if (m_part)
+    {
+        //WABA: Is this Ok? Do I need to deref it as well?
+        //Does this need to be done somewhere else?
+        DOM::DocumentImpl *doc = m_part->xmlDocImpl();
+        if (doc)
+            doc->detach();
+    }
+#endif /* APPLE_CHANGES not defined */
     lstViews->removeRef( this );
     if(lstViews->isEmpty())
     {
@@ -217,6 +238,11 @@ void KHTMLView::init()
     lstViews->setAutoDelete( FALSE );
     lstViews->append( this );
 
+#ifndef APPLE_CHANGES
+    if(!d->paintBuffer) d->paintBuffer = new QPixmap(PAINT_BUFFER_HEIGHT, PAINT_BUFFER_HEIGHT);
+   if(!d->tp) d->tp = new QPainter();
+#endif /* APPLE_CHANGES not defined */
+
     setFocusPolicy(QWidget::StrongFocus);
     viewport()->setFocusPolicy( QWidget::WheelFocus );
     viewport()->setFocusProxy(this);
@@ -277,13 +303,12 @@ void KHTMLView::resizeEvent (QResizeEvent* e)
     KApplication::sendPostedEvents(viewport(), QEvent::Paint);
 }
 
-#ifdef KWQ_RENDER_TREE_DEBUG
+#ifdef APPLE_RENDER_TREE_DEBUG
 static void printLevel(int level){
     while (level--)
         printf ("    ");
 }
 
-
 static void printRenderTree(RenderObject *node, int level)
 {
     printLevel (level);
@@ -294,9 +319,8 @@ static void printRenderTree(RenderObject *node, int level)
         child = child->nextSibling();
     }
 }
-#endif
-
 
+#endif /* APPLE_RENDER_TREE_DEBUG */
 void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
 {
     if(!m_part->xmlDocImpl()) {
@@ -304,6 +328,7 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
         return;
     }
 
+#ifdef APPLE_CHANGES
     // FIXME!
     RenderObject *ro;
     DOM::DocumentImpl *doc;
@@ -312,19 +337,45 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
     if (doc){
         ro = doc->renderer();
         if (ro){
-#ifdef KWQ_RENDER_TREE_DEBUG
+#ifdef APPLE_RENDER_TREE_DEBUG
                 printRenderTree (ro, 0);
-#endif
+#endif /* APPLE_RENDER_TREE_DEBUG */
             ro->print(p, ex, ey, ew, eh, 0, 0);
         }
     }
+#else /* APPLE_CHANGES not defined */
+    //kdDebug( 6000 ) << "drawContents x=" << ex << ",y=" << ey << ",w=" << ew << ",h=" << eh << endl;
+
+    if ( d->paintBuffer->width() < visibleWidth() )
+        d->paintBuffer->resize(visibleWidth(),PAINT_BUFFER_HEIGHT);
+
+    int py=0;
+    while (py < eh) {
+        int ph = eh-py < PAINT_BUFFER_HEIGHT ? eh-py : PAINT_BUFFER_HEIGHT;
+        d->tp->begin(d->paintBuffer);
+        d->tp->translate(-ex, -ey-py);
+        d->tp->fillRect(ex, ey+py, ew, ph, palette().normal().brush(QColorGroup::Base));
+        m_part->xmlDocImpl()->renderer()->print(d->tp, ex, ey+py, ew, ph, 0, 0);
+#ifdef BOX_DEBUG
+	if (m_part->xmlDocImpl()->focusNode())
+	{
+	    d->tp->setBrush(Qt::NoBrush);
+	    d->tp->drawRect(m_part->xmlDocImpl()->focusNode()->getRect());
+	}
+#endif
+        d->tp->end();
+
+        p->drawPixmap(ex, ey+py, *d->paintBuffer, 0, 0, ew, ph);
+        py += PAINT_BUFFER_HEIGHT;
+    }
+#endif /* APPLE_CHANGES not defined */
 
     khtml::DrawContentsEvent event( p, ex, ey, ew, eh );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
+#endif /* APPLE_CHANGES not defined */
 }
 
 void KHTMLView::layout(bool)
@@ -335,28 +386,32 @@ void KHTMLView::layout(bool)
 
         khtml::RenderRoot* root = static_cast<khtml::RenderRoot *>(document->renderer());
 
+#ifdef APPLE_CHANGES
         if (root != 0){
-            if (document->isHTMLDocument()) {
-                NodeImpl *body = static_cast<HTMLDocumentImpl*>(document)->body();
-                if(body && body->renderer() && body->id() == ID_FRAMESET) {
-                    QScrollView::setVScrollBarMode(AlwaysOff);
-                    QScrollView::setHScrollBarMode(AlwaysOff);
-                    _width = visibleWidth();
-                    body->renderer()->setLayouted(false);
-                    body->renderer()->layout();
-                    root->layout();
-                    return;
-                }
+#endif /* APPLE_CHANGES */
+        if (document->isHTMLDocument()) {
+            NodeImpl *body = static_cast<HTMLDocumentImpl*>(document)->body();
+            if(body && body->renderer() && body->id() == ID_FRAMESET) {
+                QScrollView::setVScrollBarMode(AlwaysOff);
+                QScrollView::setHScrollBarMode(AlwaysOff);
+                _width = visibleWidth();
+                body->renderer()->setLayouted(false);
+                body->renderer()->layout();
+                root->layout();
+                return;
             }
-        
-            _height = visibleHeight();
-            _width = visibleWidth();
-        
-            //QTime qt;
-            //qt.start();
+        }
+#ifdef APPLE_CHANGES
+        }
+#endif /* APPLE_CHANGES */
+
+        _height = visibleHeight();
+        _width = visibleWidth();
+
+        //QTime qt;
+        //qt.start();
             root->layout();
             //kdDebug( 6000 ) << "TIME: layout() dt=" << qt.elapsed() << endl;
-        }
     } else {
         _width = visibleWidth();
     }
@@ -406,11 +461,11 @@ void KHTMLView::viewportMousePressEvent( QMouseEvent *_mouse )
 
     khtml::MousePressEvent event( _mouse, xm, ym, mev.url, mev.innerNode );
     event.setNodePos( mev.nodeAbsX, mev.nodeAbsY );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
+#endif /* APPLE_CHANGES not defined */
 
     emit m_part->nodeActivated(mev.innerNode);
 }
@@ -448,12 +503,11 @@ void KHTMLView::viewportMouseDoubleClickEvent( QMouseEvent *_mouse )
 
     khtml::MouseDoubleClickEvent event( _mouse, xm, ym, mev.url, mev.innerNode );
     event.setNodePos( mev.nodeAbsX, mev.nodeAbsY );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
-
+#endif /* APPLE_CHANGES not defined */
 
     // ###
     //if ( url.length() )
@@ -543,12 +597,11 @@ void KHTMLView::viewportMouseMoveEvent( QMouseEvent * _mouse )
 
     khtml::MouseMoveEvent event( _mouse, xm, ym, mev.url, mev.innerNode );
     event.setNodePos( mev.nodeAbsX, mev.nodeAbsY );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
-
+#endif /* APPLE_CHANGES not defined */
 }
 
 void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse )
@@ -576,12 +629,11 @@ void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse )
 
     khtml::MouseReleaseEvent event( _mouse, xm, ym, mev.url, mev.innerNode );
     event.setNodePos( mev.nodeAbsX, mev.nodeAbsY );
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     m_part->event (&event);
-#else
+#else /* APPLE_CHANGES not defined */
     QApplication::sendEvent( m_part, &event );
-#endif
-
+#endif /* APPLE_CHANGES not defined */
 }
 
 void KHTMLView::keyPressEvent( QKeyEvent *_ke )
@@ -1093,8 +1145,12 @@ void KHTMLView::addFormCompletionItem(const QString &name, const QString &value)
     // dashes or spaces as those are likely credit card numbers or
     // something similar
     bool cc_number(true);
+#ifdef APPLE_CHANGES
     // [kocienda] fixed signed/unsigned int comparison
     for (unsigned int i = 0; i < value.length(); ++i)
+#else /* APPLE_CHANGES not defined */
+    for (int i = 0; i < value.length(); ++i)
+#endif /* APPLE_CHANGES not defined */
     {
       QChar c(value[i]);
       if (!c.isNumber() && c != '-' && !c.isSpace())
diff --git a/WebCore/src/kdelibs/khtml/khtmlview.h b/WebCore/src/kdelibs/khtml/khtmlview.h
index 76e848b..5b8e884 100644
--- a/WebCore/src/kdelibs/khtml/khtmlview.h
+++ b/WebCore/src/kdelibs/khtml/khtmlview.h
@@ -53,8 +53,9 @@ namespace khtml {
     void applyRule(RenderStyle *style, DOM::CSSProperty *prop, DOM::ElementImpl *e);
 };
 
+#ifdef APPLE_CHANGES
 #include "khtml_part.h"
-
+#endif /* APPLE_CHANGES */
 class KHTMLPart;
 class KHTMLViewPrivate;
 
@@ -172,12 +173,20 @@ public:
 
     static const QList<KHTMLView> *viewList() { return lstViews; }
 
-    virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
+signals:
+    void cleared();
 
+protected:
+    void clear();
+
+#ifdef APPLE_CHANGES
+public:
+#endif /* APPLE_CHANGES */
     virtual void resizeEvent ( QResizeEvent * event );
     virtual void showEvent ( QShowEvent * );
     virtual void hideEvent ( QHideEvent *);
     virtual bool focusNextPrevChild( bool next );
+    virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
 
     virtual void viewportMousePressEvent( QMouseEvent * );
     virtual void focusOutEvent( QFocusEvent * );
@@ -208,13 +217,6 @@ public:
      */
     void doAutoScroll();
 
-signals:
-    void cleared();
-
-    void clear();
-
-protected:
-
 protected slots:
     void slotPaletteChanged();
 
diff --git a/WebCore/src/kdelibs/khtml/misc/decoder.cpp b/WebCore/src/kdelibs/khtml/misc/decoder.cpp
index 89d0462..2927754 100644
--- a/WebCore/src/kdelibs/khtml/misc/decoder.cpp
+++ b/WebCore/src/kdelibs/khtml/misc/decoder.cpp
@@ -84,7 +84,7 @@ void Decoder::setEncoding(const char *_encoding, bool force)
     if( !b ) // in case the codec didn't exist, we keep the old one (fixes some sites specifying invalid codecs)
 	m_codec = old;
     else
-        haveEncoding = force;
+	haveEncoding = force;
     delete m_decoder;
     m_decoder = m_codec->makeDecoder();
 #ifdef DECODE_DEBUG
@@ -230,12 +230,12 @@ QString Decoder::decode(const char *data, int len)
             }
             return QString::null;
         }
-    } 
-#ifdef _KWQ_
+    }
+#ifdef APPLE_CHANGES
     else {
         buffer += QCString(data, len+1);
-    }
-#endif
+    } 
+#endif /* APPLE_CHANGES */
 
  found:
     // if we still haven't found an encoding latin1 will be used...
diff --git a/WebCore/src/kdelibs/khtml/misc/helper.cpp b/WebCore/src/kdelibs/khtml/misc/helper.cpp
index dca84ae..81658d4 100644
--- a/WebCore/src/kdelibs/khtml/misc/helper.cpp
+++ b/WebCore/src/kdelibs/khtml/misc/helper.cpp
@@ -153,16 +153,21 @@ using namespace khtml;
 
 static HTMLColors *htmlColors = 0L;
 
+#ifdef APPLE_CHANGES
 // FIXME: do we really need static delete support here?
-//static KStaticDeleter<HTMLColors> hcsd;
+#else /* APPLE_CHANGES not defined */
+static KStaticDeleter<HTMLColors> hcsd;
+#endif /* APPLE_CHANGES not defined */
 
 void khtml::setNamedColor(QColor &color, const QString &_name)
 {
-    if( !htmlColors ) {
+    if( !htmlColors )
+#ifdef APPLE_CHANGES
         // FIXME: do we really need static delete support here?
-        // htmlColors = hcsd.setObject( new HTMLColors );
         htmlColors = new HTMLColors();
-    }
+#else /* APPLE_CHANGES not defined */
+        htmlColors = hcsd.setObject( new HTMLColors );
+#endif /* APPLE_CHANGES not defined */
 
     int pos;
     QString name = _name;
@@ -180,16 +185,38 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
     // also recognize "color=ffffff"
     if (len == 6)
     {
+#ifdef APPLE_CHANGES
         // recognize #12345 (append a '0')
         if(name[0] == '#') {
             name += '0';
         }
         else if ((!name[0].isLetter() && !name[0].isDigit())) {
-            color = QColor();
-            return;
-	    }
-        
+	    color = QColor();
+	    return;
+	}
         color.setNamedColor(name);
+#else /* APPLE_CHANGES not defined */
+        bool ok;
+        int val = name.toInt(&ok, 16);
+        if(ok)
+        {
+            color.setRgb((0xff << 24) | val);
+            return;
+        }
+        // recognize #12345 (duplicate the last character)
+        if(name[0] == '#') {
+            bool ok;
+            int val = name.right(5).toInt(&ok, 16);
+            if(ok) {
+                color.setRgb((0xff << 24) | (val * 16 + ( val&0xf )));
+                return;
+            }
+        }
+        if ( !name[0].isLetter() ) {
+	    color = QColor();
+	    return;
+	}
+#endif /* APPLE_CHANGES not defined */
     }
 
     // #fffffff as found on msdn.microsoft.com
@@ -227,13 +254,11 @@ void khtml::setNamedColor(QColor &color, const QString &_name)
     else
     {
         QColor tc = htmlColors->map[name];
-        
-        if (!tc.isValid()) {
+        if ( !tc.isValid() )
             tc = htmlColors->map[name.lower()];
-        }
-        if (tc.isValid()) {
+
+        if (tc.isValid())
             color = tc;
-        }
         else {
             color.setNamedColor(name);
             if ( !color.isValid() )  color.setNamedColor( name.lower() );
diff --git a/WebCore/src/kdelibs/khtml/misc/loader.h b/WebCore/src/kdelibs/khtml/misc/loader.h
index ec7edf0..df810a1 100644
--- a/WebCore/src/kdelibs/khtml/misc/loader.h
+++ b/WebCore/src/kdelibs/khtml/misc/loader.h
@@ -66,8 +66,10 @@ namespace khtml
 {
     class CachedObject;
     class Request;
+#ifdef APPLE_CHANGES
     class LoaderPrivate;
     class DocLoader;
+#endif /* APPLE_CHANGES */
 
     /**
      * @internal
@@ -96,9 +98,15 @@ namespace khtml
 	    Uncacheable   // to big to be cached,
 	};  	          // will be destroyed as soon as possible
 
+#ifdef APPLE_CHANGES
 	CachedObject(const DocLoader *loader, const DOM::DOMString &url, Type type, bool _reload, int _expireDate)
+#else /* APPLE_CHANGES not defined */
+	CachedObject(const DOM::DOMString &url, Type type, bool _reload, int _expireDate)
+#endif /* APPLE_CHANGES not defined */
 	{
+#ifdef APPLE_CHANGES
 	    m_loader = loader;
+#endif /* APPLE_CHANGES */
 	    m_url = url;
 	    m_type = type;
 	    m_status = Pending;
@@ -107,12 +115,12 @@ namespace khtml
 	    m_reload = _reload;
 	    m_request = 0;
 	    m_expireDate = _expireDate;
-        m_deleted = false;
+            m_deleted = false;
 	}
 	virtual ~CachedObject() {
-        if(m_deleted) abort();
+            if(m_deleted) abort();
             m_deleted = true;
-    }
+        }
 
 	virtual void data( QBuffer &buffer, bool eof) = 0;
 	virtual void error( int err, const char *text ) = 0;
@@ -137,47 +145,47 @@ namespace khtml
 	 */
 	void finish();
 
-    /*
-     * Called by the cache if the object has been removed from the cache dict
-     * while still being referenced. This means the object should kill itself
-     * if its reference counter drops down to zero.
-     */
-    void setFree( bool b ) { m_free = b; }
-    
-    bool reload() const { return m_reload; }
-    
-    void setRequest(Request *_request);
-    
-    bool canDelete() const { return (m_clients.count() == 0 && !m_request); }
+        /*
+         * Called by the cache if the object has been removed from the cache dict
+         * while still being referenced. This means the object should kill itself
+         * if its reference counter drops down to zero.
+         */
+        void setFree( bool b ) { m_free = b; }
 
-	void setExpireDate(int _expireDate);
+        bool reload() const { return m_reload; }
 
-    /*
-     * List of acceptable mimetypes seperated by ",". A mimetype may contain a wildcard.
-     */
-    // e.g. "text/*"
-    QString accept() const { return m_accept; }
-    void setAccept(const QString &_accept) { m_accept = _accept; }
+        void setRequest(Request *_request);
 
+        bool canDelete() const { return (m_clients.count() == 0 && !m_request); }
+
+	void setExpireDate(int _expireDate);
 
+        /*
+         * List of acceptable mimetypes seperated by ",". A mimetype may contain a wildcard.
+         */
+        // e.g. "text/*"
+        QString accept() const { return m_accept; }
+        void setAccept(const QString &_accept) { m_accept = _accept; }
+#ifdef APPLE_CHANGES
     const DocLoader *loader() { return m_loader; }
-    
-    protected:
+#endif /* APPLE_CHANGES */
 
-    const DocLoader *m_loader;
-    
-    QList<CachedObjectClient> m_clients;
+    protected:
+#ifdef APPLE_CHANGES
+        const DocLoader *m_loader;
+#endif /* APPLE_CHANGES */
+        QList<CachedObjectClient> m_clients;
         
 	DOM::DOMString m_url;
-    QString m_accept;
-    Request *m_request;
+        QString m_accept;
+        Request *m_request;
 	Type m_type;
 	Status m_status;
 	int m_size;
 	int m_expireDate;
-    bool m_free;
-    bool m_reload;
-    bool m_deleted;
+        bool m_free;
+        bool m_reload;
+        bool m_deleted;
     };
 
 
@@ -187,7 +195,11 @@ namespace khtml
     class CachedCSSStyleSheet : public CachedObject
     {
     public:
+#ifdef APPLE_CHANGES
 	CachedCSSStyleSheet(const DocLoader *loader, const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate, const QString& charset);
+#else /* APPLE_CHANGES not defined */
+	CachedCSSStyleSheet(const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate, const QString& charset);
+#endif /* APPLE_CHANGES not defined */
 	virtual ~CachedCSSStyleSheet();
 
 	const DOM::DOMString &sheet() const { return m_sheet; }
@@ -212,7 +224,11 @@ namespace khtml
     class CachedScript : public CachedObject
     {
     public:
+#ifdef APPLE_CHANGES
 	CachedScript(const DocLoader *loader, const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate, const QString& charset);
+#else /* APPLE_CHANGES not defined */
+	CachedScript(const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate, const QString& charset);
+#endif /* APPLE_CHANGES not defined */
 	virtual ~CachedScript();
 
 	const DOM::DOMString &script() const { return m_script; }
@@ -240,7 +256,11 @@ namespace khtml
     {
 	Q_OBJECT
     public:
+#ifdef APPLE_CHANGES
 	CachedImage(const DocLoader *loader, const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate);
+#else /* APPLE_CHANGES not defined */
+	CachedImage(const DOM::DOMString &url, const DOM::DOMString &baseURL, bool reload, int _expireDate);
+#endif /* APPLE_CHANGES not defined */
 	virtual ~CachedImage();
 
 	const QPixmap &pixmap() const;
@@ -322,7 +342,9 @@ namespace khtml
         void setReloading( bool );
         void setShowAnimations( bool );
         void removeCachedObject( CachedObject*) const;
+#ifdef APPLE_CHANGES
         const KHTMLPart *part() { return m_part; }
+#endif /* APPLE_CHANGES */
 
     private:
         friend class Cache;
@@ -349,9 +371,9 @@ namespace khtml
 	QBuffer m_buffer;
 	CachedObject *object;
 	DOM::DOMString m_baseURL;
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void *client;
-#endif
+#endif /* APPLE_CHANGES */
     };
 
     /**
@@ -379,15 +401,15 @@ namespace khtml
 	void requestDone( const DOM::DOMString &baseURL, khtml::CachedObject *obj );
 	void requestFailed( const DOM::DOMString &baseURL, khtml::CachedObject *obj );
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     public:
 	void slotFinished( KIO::Job * );
 	void slotData( KIO::Job *, const char *data, int size );
-#else
+#else /* APPLE_CHANGES not defined */
     protected slots:
 	void slotFinished( KIO::Job * );
 	void slotData( KIO::Job *, const QByteArray & );
-#endif
+#endif /* APPLE_CHANGES not defined */
 
     private:
 	void servePendingRequests();
@@ -397,13 +419,13 @@ namespace khtml
 #ifdef HAVE_LIBJPEG
         KJPEGFormatType m_jpegloader;
 #endif
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 #if (defined(__APPLE__) && defined(__OBJC__) && defined(__cplusplus))
     LoaderPrivate *d;
-#else
+#else /* __APPLE__, __OBJC__, __cplusplus not defined */
     void *d;    
-#endif // __APPLE__, __OBJC__, __cplusplus
-#endif // _KWQ_
+#endif /* __APPLE__, __OBJC__, __cplusplus not defined */
+#endif /* APPLE_CHANGES */
     };
 
         /**
diff --git a/WebCore/src/kdelibs/khtml/rendering/bidi.cpp b/WebCore/src/kdelibs/khtml/rendering/bidi.cpp
index f97de56..2dc0114 100644
--- a/WebCore/src/kdelibs/khtml/rendering/bidi.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/bidi.cpp
@@ -851,11 +851,11 @@ void RenderFlow::layoutInlineChildren()
             if(!m_pre) {
                 // remove leading spaces
 #ifndef QT_NO_UNICODETABLES
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
                 while(!start.atEnd() && start.current() == ' ' )
-#else
+#else /* APPLE_CHANGES not defined */
                 while(!start.atEnd() && start.direction() == QChar::DirWS )
-#endif
+#endif /* APPLE_CHANGES not defined */
 #else
                 while(!start.atEnd() && start.current() == ' ' )
 #endif
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_applet.cpp b/WebCore/src/kdelibs/khtml/rendering/render_applet.cpp
index 47c4dd7..0e2be5b 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_applet.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_applet.cpp
@@ -35,10 +35,9 @@
 #include <java/kjavaappletwidget.h>
 #include <misc/htmltags.h>
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 #include <WCJavaAppletWidget.h>
-#endif
-
+#endif /* APPLE_CHANGES */
 using namespace khtml;
 using namespace DOM;
 
@@ -49,10 +48,10 @@ RenderApplet::RenderApplet(QScrollView *view,
     // init RenderObject attributes
     setInline(true);
     m_applet = applet;
-    
-#ifdef _KWQ_
+
+#ifdef APPLE_CHANGES
     setQWidget( new WCJavaAppletWidget(args));
-#else
+#else /* APPLE_CHANGES not defined */
     KJavaAppletContext *context = 0;
     KHTMLView *_view = static_cast<KHTMLView*>(view);
     if ( _view ) {
@@ -65,7 +64,7 @@ RenderApplet::RenderApplet(QScrollView *view,
         setQWidget( new KJavaAppletWidget(context, view->viewport()) );
         processArguments(args);
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
 }
 
 RenderApplet::~RenderApplet()
@@ -102,11 +101,11 @@ void RenderApplet::layout()
 
     calcWidth();
     calcHeight();
-    
-#ifdef _KWQ_
+
+#ifdef APPLE_CHANGES
     m_widget->resize(m_width-marginLeft()-marginRight()-paddingLeft()-paddingRight(),
         m_height-marginTop()-marginBottom()-paddingTop()-paddingBottom());
-#else
+#else /* APPLE_CHANGES not defined */
     KJavaAppletWidget *tmp = static_cast<KJavaAppletWidget*>(m_widget);
     if ( tmp ) {
         NodeImpl *child = m_applet->firstChild();
@@ -125,7 +124,8 @@ void RenderApplet::layout()
                          m_height-marginTop()-marginBottom()-paddingTop()-paddingBottom());
         tmp->showApplet();
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
+
     setLayouted();
 }
 
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_body.cpp b/WebCore/src/kdelibs/khtml/rendering/render_body.cpp
index c5b9f91..a5f2f59 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_body.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_body.cpp
@@ -96,8 +96,10 @@ void RenderBody::layout()
     {
         if (root()->view())
         {
-            //root()->view()->horizontalScrollBar()->setPalette(style()->palette());
-            //root()->view()->verticalScrollBar()->setPalette(style()->palette());
+#ifndef APPLE_CHANGES
+            root()->view()->horizontalScrollBar()->setPalette(style()->palette());
+            root()->view()->verticalScrollBar()->setPalette(style()->palette());
+#endif /* APPLE_CHANGES not defined */
         }
         scrollbarsStyled=true;
     }
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_box.cpp b/WebCore/src/kdelibs/khtml/rendering/render_box.cpp
index 1d6605f..b23829f 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_box.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_box.cpp
@@ -207,7 +207,6 @@ void RenderBox::printBackground(QPainter *p, const QColor &c, CachedImage *bg, i
     if(c.isValid())
         p->fillRect(_tx, clipy, w, cliph, c);
     // no progressive loading of the background image
-    
     if(bg && bg->pixmap_size() == bg->valid_rect().size() && !bg->isTransparent() && !bg->isErrorImage()) {
         //kdDebug( 6040 ) << "printing bgimage at " << _tx << "/" << _ty << endl;
         // ### might need to add some correct offsets
@@ -296,15 +295,14 @@ void RenderBox::printBackground(QPainter *p, const QColor &c, CachedImage *bg, i
 
 //        kdDebug() << "cx="<<cx << " cy="<<cy<< " cw="<<cw << " ch="<<ch << " sx="<<sx << " sy="<<sy << endl;
         
-        if (cw>0 && ch>0) {
-#ifdef _KWQ_
+        if (cw>0 && ch>0)
+#ifdef APPLE_CHANGES
             // This is a change in behavior. The difference is that we 
             // do not do a fill of the passed in color before tiling.
             p->drawTiledPixmap(cx, cy, cw, ch, bg->pixmap(), sx, sy);
-#else
+#else /* APPLE_CHANGES not defined */
             p->drawTiledPixmap(cx, cy, cw, ch, bg->tiled_pixmap(c), sx, sy);
-#endif
-        }
+#endif /* APPLE_CHANGES not defined */
     }
 }
 
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_flow.cpp b/WebCore/src/kdelibs/khtml/rendering/render_flow.cpp
index 6c5b65a..5f27411 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_flow.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_flow.cpp
@@ -137,7 +137,9 @@ void RenderFlow::print(QPainter *p, int _x, int _y, int _w, int _h,
         if((_ty > _y + _h) || (_ty + h < _y))
         {
             //kdDebug( 6040 ) << "cut!" << endl;
-            //return;
+#ifndef APPLE_CHANGES
+            return;
+#endif /* APPLE_CHANGES not defined */
         }
     }
         
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_form.cpp b/WebCore/src/kdelibs/khtml/rendering/render_form.cpp
index 025a870..74783f4 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_form.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_form.cpp
@@ -22,6 +22,7 @@
  *
  * $Id$
  */
+
 #include <kdebug.h>
 #include <kurl.h>
 #include <klocale.h>
@@ -73,7 +74,11 @@ RenderFormElement::~RenderFormElement()
 
 short RenderFormElement::baselinePosition( bool f ) const
 {
+#ifdef APPLE_CHANGES
     return RenderWidget::baselinePosition( f ) - 6 - QFontMetrics( style()->font() ).descent();
+#else /* APPLE_CHANGES not defined */
+    return RenderWidget::baselinePosition( f ) - 2 - QFontMetrics( style()->font() ).descent();
+#endif /* APPLE_CHANGES not defined */
 }
 
 short RenderFormElement::calcReplacedWidth(bool*) const
@@ -258,6 +263,7 @@ bool RenderFormElement::eventFilter(QObject* /*o*/, QEvent* e)
     return deleted;
 }
 
+#ifdef APPLE_CHANGES
 void RenderFormElement::performAction(QObject::Actions action)
 {
     //fprintf (stdout, "RenderFormElement::performAction():  %d\n", action);
@@ -269,9 +275,12 @@ void RenderFormElement::performAction(QObject::Actions action)
         slotClicked();
 }
 
+#endif /* APPLE_CHANGES */
 void RenderFormElement::slotClicked()
 {
+#ifdef APPLE_CHANGES
     //fprintf (stdout, "RenderFormElement::slotClicked():\n");
+#endif /* APPLE_CHANGES */
     if(isRenderButton()) {
         QMouseEvent e2( QEvent::MouseButtonRelease, m_mousePos, m_button, m_state);
 
@@ -322,9 +331,13 @@ RenderCheckBox::RenderCheckBox(QScrollView *view,
     b->setMouseTracking(true);
     setQWidget(b);
     b->installEventFilter(this);
-
+#ifdef APPLE_CHANGES
     connect(b, "SIGNAL(stateChanged(int))", this, "SLOT(slotStateChanged(int))");
     connect(b, "SIGNAL(clicked())", this, "SLOT(slotClicked())");
+#else /* APPLE_CHANGES not defined */
+    connect(b,SIGNAL(stateChanged(int)),this,SLOT(slotStateChanged(int)));
+    connect(b, SIGNAL(clicked()), this, SLOT(slotClicked()));
+#endif /* APPLE_CHANGES not defined */
 }
 
 
@@ -349,7 +362,7 @@ void RenderCheckBox::layout()
     RenderButton::layout();
 }
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 void RenderCheckBox::performAction(QObject::Actions action)
 {
     QCheckBox* cb = static_cast<QCheckBox*>( m_widget );
@@ -358,11 +371,10 @@ void RenderCheckBox::performAction(QObject::Actions action)
     if (action == QObject::ACTION_CHECKBOX_CLICKED)
         slotStateChanged(cb->isChecked() ? 2 : 0);
 }
-#endif
-
 
 // From the Qt documentation:
 // state is 2 if the button is on, 1 if it is in the "no change" state or 0 if the button is off. 
+#endif /* APPLE_CHANGES */
 void RenderCheckBox::slotStateChanged(int state)
 {
     m_element->setAttribute(ATTR_CHECKED,state == 2 ? "" : 0);
@@ -379,7 +391,11 @@ RenderRadioButton::RenderRadioButton(QScrollView *view,
     b->setMouseTracking(true);
     setQWidget(b);
     b->installEventFilter(this);
+#ifdef APPLE_CHANGES
     connect(b, "SIGNAL(clicked())", this, "SLOT(slotClicked())");
+#else /* APPLE_CHANGES not defined */
+    connect(b, SIGNAL(clicked()), this, SLOT(slotClicked()));
+#endif /* APPLE_CHANGES not defined */
 }
 
 void RenderRadioButton::setChecked(bool checked)
@@ -389,8 +405,9 @@ void RenderRadioButton::setChecked(bool checked)
 
 void RenderRadioButton::slotClicked()
 {
+#ifdef APPLE_CHANGES
     //fprintf (stdout, "RenderRadioButton::slotClicked():\n");
-
+#endif /* APPLE_CHANGES */
     m_element->setAttribute(ATTR_CHECKED,"");
 
     // emit mouseClick event etc
@@ -428,12 +445,16 @@ RenderSubmitButton::RenderSubmitButton(QScrollView *view, HTMLInputElementImpl *
     setQWidget(p);
     p->setMouseTracking(true);
     p->installEventFilter(this);
+#ifdef APPLE_CHANGES
     connect(p, "SIGNAL(clicked())", this, "SLOT(slotClicked())");
     
     // Need to store a reference to this object and then invoke slotClicked on it.
     //p->setAction (&RenderFormElement::slotClicked);
     //p->setRenderObject (this);
     p->setTarget (this);
+#else /* APPLE_CHANGES not defined */
+    connect(p, SIGNAL(clicked()), this, SLOT(slotClicked()));
+#endif /* APPLE_CHANGES not defined */
 }
 
 void RenderSubmitButton::calcMinMaxWidth()
@@ -476,10 +497,14 @@ QString RenderSubmitButton::defaultLabel() {
 
 short RenderSubmitButton::baselinePosition( bool f ) const
 {
+#ifdef APPLE_CHANGES
     //return RenderFormElement::baselinePosition( f );
     // FIXED: [rjw] Where does this magic number '8' come from.  It's also used above in
     // RenderSubmitButton::calcMinMaxWidth().
     return RenderWidget::baselinePosition( f ) - 8 - QFontMetrics( style()->font() ).descent();
+#else /* APPLE_CHANGES not defined */
+    return RenderFormElement::baselinePosition( f );
+#endif /* APPLE_CHANGES not defined */
 }
 
 // -------------------------------------------------------------------------------
@@ -552,11 +577,13 @@ RenderLineEdit::RenderLineEdit(QScrollView *view, HTMLInputElementImpl *element)
 {
     LineEditWidget *edit = new LineEditWidget(view->viewport());
     edit->installEventFilter(this);
-
-#ifdef _KWQ_    
+#ifdef APPLE_CHANGES
     connect(edit,"SIGNAL(returnPressed())", this, "SLOT(slotReturnPressed())");
     connect(edit,"SIGNAL(textChanged(const QString &))", this, "SLOT(slotTextChanged(const QString &))");
-#endif
+#else /* APPLE_CHANGES not defined */
+    connect(edit,SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
+    connect(edit,SIGNAL(textChanged(const QString &)),this,SLOT(slotTextChanged(const QString &)));
+#endif /* APPLE_CHANGES not defined */
 
     if(element->inputType() == HTMLInputElementImpl::PASSWORD)
         edit->setEchoMode( QLineEdit::Password );
@@ -570,14 +597,12 @@ RenderLineEdit::RenderLineEdit(QScrollView *view, HTMLInputElementImpl *element)
         }
     }
 
-#ifdef _KWQ_
     setQWidget(edit);
-
+#ifdef APPLE_CHANGES
     edit->setTarget (this);
-#endif
+#endif /* APPLE_CHANGES */
 }
 
-
 void RenderLineEdit::slotReturnPressed()
 {
     // don't submit the form when return was pressed in a completion-popup
@@ -617,7 +642,11 @@ void RenderLineEdit::calcMinMaxWidth()
             h = 22;
         s = QSize( w + 8, h ).expandedTo( QApplication::globalStrut() );
     } else
+#ifdef APPLE_CHANGES
 	s = QSize( w + 6, h + 6 ).expandedTo( QApplication::globalStrut() );
+#else /* APPLE_CHANGES not defined */
+	s = QSize( w + 4, h + 4 ).expandedTo( QApplication::globalStrut() );
+#endif /* APPLE_CHANGES not defined */
 
     setIntrinsicWidth( s.width() );
     setIntrinsicHeight( s.height() );
@@ -647,7 +676,7 @@ void RenderLineEdit::layout()
     RenderFormElement::layout();
 }
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 void RenderLineEdit::performAction(QObject::Actions action)
 {
     KLineEdit *edit = static_cast<KLineEdit*>(m_widget);
@@ -658,8 +687,8 @@ void RenderLineEdit::performAction(QObject::Actions action)
     else if (action == QObject::ACTION_TEXT_FIELD)
         slotReturnPressed();
 }
-#endif
 
+#endif /* APPLE_CHANGES */
 void RenderLineEdit::slotTextChanged(const QString &string)
 {
     // don't use setValue here!
@@ -690,12 +719,21 @@ RenderFileButton::RenderFileButton(QScrollView *view, HTMLInputElementImpl *elem
 
     m_edit->installEventFilter(this);
 
+#ifdef APPLE_CHANGES
     connect(m_edit, "SIGNAL(returnPressed())", this, "SLOT(slotReturnPressed())");
     connect(m_edit, "SIGNAL(textChanged(const QString &))", this, "SLOT(slotTextChanged(const QString &))");
+#else /* APPLE_CHANGES not defined */
+    connect(m_edit, SIGNAL(returnPressed()), this, SLOT(slotReturnPressed()));
+    connect(m_edit, SIGNAL(textChanged(const QString &)),this,SLOT(slotTextChanged(const QString &)));
+#endif /* APPLE_CHANGES not defined */
 
     m_button = new QPushButton(i18n("Browse..."), w);
     m_button->setFocusPolicy(QWidget::ClickFocus);
+#ifdef APPLE_CHANGES
     connect(m_button, "SIGNAL(clicked())", this, "SLOT(slotClicked())");
+#else /* APPLE_CHANGES not defined */
+    connect(m_button,SIGNAL(clicked()), this, SLOT(slotClicked()));
+#endif /* APPLE_CHANGES not defined */
 
     w->setStretchFactor(m_edit, 2);
     w->setFocusProxy(m_edit);
@@ -860,7 +898,7 @@ RenderSelect::RenderSelect(QScrollView *view, HTMLSelectElementImpl *element)
     if(m_useListBox)
         setQWidget(createListBox());
     else
-	    setQWidget(createComboBox());
+	setQWidget(createComboBox());
 }
 
 
@@ -934,7 +972,8 @@ void RenderSelect::layout( )
 
                 if(m_useListBox) {
                     QListBoxText *item = new QListBoxText(QString(text.implementation()->s, text.implementation()->l).visual());
-                    static_cast<KListBox*>(m_widget)->insertItem(item, listIndex);
+                    static_cast<KListBox*>(m_widget)
+                        ->insertItem(item, listIndex);
                     item->setSelectable(false);
                 }
                 else
@@ -988,16 +1027,16 @@ void RenderSelect::layout( )
         if(size < 1)
             size = QMIN(static_cast<KListBox*>(m_widget)->count(), 10);
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
         width += w->scrollBarWidth();
         height = size*height;
         // NSBrowser has problems drawing scrollbar correctly when it's size is too small.
         if (height < 60)
             height = 60;
-#else
+#else /* APPLE_CHANGES not defined */
         width += 2*w->frameWidth() + w->verticalScrollBar()->sizeHint().width();
         height = size*height + 2*w->frameWidth();
-#endif
+#endif /* APPLE_CHANGES not defined */
 
         setIntrinsicWidth( width );
         setIntrinsicHeight( height );
@@ -1082,6 +1121,7 @@ void RenderSelect::slotSelected(int index)
 }
 
 
+#ifdef APPLE_CHANGES
 void RenderSelect::performAction(QObject::Actions action)
 {
     //fprintf (stdout, "RenderSelect::performAction():  %d\n", action);
@@ -1094,6 +1134,7 @@ void RenderSelect::performAction(QObject::Actions action)
     }
 }
 
+#endif /* APPLE_CHANGES */
 void RenderSelect::slotSelectionChanged()
 {
     if ( m_ignoreSelectEvents ) return;
@@ -1122,7 +1163,11 @@ KListBox* RenderSelect::createListBox()
     lb->setSelectionMode(m_multiple ? QListBox::Extended : QListBox::Single);
     // ### looks broken
     //lb->setAutoMask(true);
+#ifdef APPLE_CHANGES
     connect( lb, "SIGNAL(selectionChanged())", this, "SLOT(slotSelectionChanged())" );
+#else /* APPLE_CHANGES not defined */
+    connect( lb, SIGNAL( selectionChanged() ), this, SLOT( slotSelectionChanged() ) );
+#endif /* APPLE_CHANGES not defined */
     m_ignoreSelectEvents = false;
     lb->setMouseTracking(true);
 
@@ -1133,7 +1178,11 @@ ComboBoxWidget *RenderSelect::createComboBox()
 {
     ComboBoxWidget *cb = new ComboBoxWidget(m_view->viewport());
     cb->installEventFilter(this);
+#ifdef APPLE_CHANGES
     connect(cb, "SIGNAL(activated(int))", this, "SLOT(slotSelected(int))");
+#else /* APPLE_CHANGES not defined */
+    connect(cb, SIGNAL(activated(int)), this, SLOT(slotSelected(int)));
+#endif /* APPLE_CHANGES not defined */
     return cb;
 }
 
@@ -1214,7 +1263,11 @@ RenderTextArea::RenderTextArea(QScrollView *view, HTMLTextAreaElementImpl *eleme
     setQWidget(edit);
     edit->installEventFilter(this);
 
+#ifdef APPLE_CHANGES
     connect(edit, "SIGNAL(textChanged())", this, "SLOT(slotTextChanged())");
+#else /* APPLE_CHANGES not defined */
+    connect(edit,SIGNAL(textChanged()),this,SLOT(slotTextChanged()));
+#endif /* APPLE_CHANGES not defined */
 }
 
 RenderTextArea::~RenderTextArea()
@@ -1232,21 +1285,21 @@ void RenderTextArea::calcMinMaxWidth()
     TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
     HTMLTextAreaElementImpl* f = static_cast<HTMLTextAreaElementImpl*>(m_element);
     QFontMetrics m = fontMetrics(style()->font());
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     QSize size( QMAX(f->cols(), 1)*m.width('x') + w->frameWidth()*5 +
                 w->verticalScrollBarWidth(),
                 QMAX(f->rows(), 1)*m.height() + w->frameWidth()*3 +
                 (w->wordWrap() == QMultiLineEdit::NoWrap ?
                  w->horizontalScrollBarHeight() : 0)
         );
-#else
+#else /* APPLE_CHANGES not defined */
     QSize size( QMAX(f->cols(), 1)*m.width('x') + w->frameWidth()*5 +
                 w->verticalScrollBar()->sizeHint().width(),
                 QMAX(f->rows(), 1)*m.height() + w->frameWidth()*3 +
                 (w->wordWrap() == QMultiLineEdit::NoWrap ?
                  w->horizontalScrollBar()->sizeHint().height() : 0)
         );
-#endif
+#endif /* APPLE_CHANGES not defined */
 
     setIntrinsicWidth( size.width() );
     setIntrinsicHeight( size.height() );
@@ -1260,13 +1313,13 @@ void RenderTextArea::layout( )
     HTMLTextAreaElementImpl* f = static_cast<HTMLTextAreaElementImpl*>(m_element);
 
     if (!layouted()) {
-        w->setReadOnly(m_element->readOnly());
-        w->blockSignals(true);
-        int line, col;
-        w->getCursorPosition( &line, &col );
-        w->setText(f->value().string().visual());
-        w->setCursorPosition( line, col );
-        w->blockSignals(false);
+	w->setReadOnly(m_element->readOnly());
+	w->blockSignals(true);
+	int line, col;
+	w->getCursorPosition( &line, &col );
+	w->setText(f->value().string().visual());
+	w->setCursorPosition( line, col );
+	w->blockSignals(false);
     }
 
     RenderFormElement::layout();
@@ -1301,6 +1354,7 @@ QString RenderTextArea::text()
     return txt;
 }
 
+#ifdef APPLE_CHANGES
 void RenderTextArea::performAction(QObject::Actions action)
 {
     //TextAreaWidget *edit = static_cast<TextAreaWidget*>(m_widget);
@@ -1310,6 +1364,7 @@ void RenderTextArea::performAction(QObject::Actions action)
         slotTextChanged();
 }
 
+#endif /* APPLE_CHANGES */
 void RenderTextArea::slotTextChanged()
 {
     static_cast<HTMLTextAreaElementImpl*>( m_element )->m_dirtyvalue = true;
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_form.h b/WebCore/src/kdelibs/khtml/rendering/render_form.h
index 9c9713b..2cb9d24 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_form.h
+++ b/WebCore/src/kdelibs/khtml/rendering/render_form.h
@@ -83,10 +83,9 @@ public:
     DOM::HTMLGenericFormElementImpl *element() { return m_element; }
 
     virtual bool eventFilter(QObject*, QEvent*);
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
+#endif /* APPLE_CHANGES */
 
 public slots:
     virtual void slotClicked();
@@ -133,10 +132,9 @@ public:
     virtual const char *renderName() const { return "RenderCheckBox"; }
     virtual void calcMinMaxWidth();
     virtual void layout( );
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
+#endif /* APPLE_CHANGES */
     
 public slots:
     virtual void slotStateChanged(int state);
@@ -225,10 +223,9 @@ public:
 
     virtual const char *renderName() const { return "RenderLineEdit"; }
     void select();
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
+#endif /* APPLE_CHANGES */
 
 public slots:
     void slotReturnPressed();
@@ -341,11 +338,9 @@ public:
     void setSelectionChanged(bool _selectionChanged) { m_selectionChanged = _selectionChanged; }
 
     void updateSelection();
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
-
+#endif /* APPLE_CHANGES */
 
 protected:
     KListBox *createListBox();
@@ -395,10 +390,9 @@ public:
 
     QString text(); // ### remove
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif
-
+#endif /* APPLE_CHANGES */
     void select();
 
 protected slots:
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_frames.cpp b/WebCore/src/kdelibs/khtml/rendering/render_frames.cpp
index 513a538..dc57e64 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_frames.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_frames.cpp
@@ -804,11 +804,12 @@ void RenderPartObject::updateWidget()
      }
 
      KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();
-     #ifdef _KWQ_
-     #else
+
+#ifndef APPLE_CHANGES
      o->param.append( QString::fromLatin1("__KHTML__PLUGINEMBED=\"YES\"") );
      o->param.append( QString::fromLatin1("__KHTML__PLUGINBASEURL=\"%1\"").arg( part->url().url() ) );
-     #endif
+#endif /* APPLE_CHANGES not defined */
+
      part->requestObject( this, url, serviceType, o->param );
 
   } else {
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_hr.cpp b/WebCore/src/kdelibs/khtml/rendering/render_hr.cpp
index 7b9829d..3f2d67f 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_hr.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_hr.cpp
@@ -69,9 +69,12 @@ void RenderHR::print(QPainter *p, int _x, int _y, int _w, int _h, int _tx, int _
         prev = prev->previousSibling();
     if(prev && static_cast<RenderFlow *>(prev)->floatBottom() > prev->height() )
         xp += static_cast<RenderFlow *>(prev)->leftOffset( prev->height() );
-    
+
+#ifdef APPLE_CHANGES
     // [kocienda] yp is unused because of #if 0 block
-    //int yp = _ty ;
+#else /* APPLE_CHANGES not defined */
+    int yp = _ty ;
+#endif /* APPLE_CHANGES not defined */
 
 
 
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_image.cpp b/WebCore/src/kdelibs/khtml/rendering/render_image.cpp
index ffa0812..62f8015 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_image.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_image.cpp
@@ -170,11 +170,11 @@ void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
         if(cWidth > 2 && cHeight > 2)
         {
             //qDebug("qDrawShadePanel %d/%d/%d/%d", _tx + leftBorder, _ty + topBorder, cWidth, cHeight);
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
             p->setPen (Qt::lightGray);
             p->setBrush (Qt::NoBrush);
             p->drawRect (_tx, _ty, cWidth, cHeight);
-#else
+#else /* APPLE_CHANGES not defined */
             qDrawShadePanel( p, _tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight,
                              KApplication::palette().inactive(), true, 1 );
             if(berrorPic && !pix.isNull() && (cWidth >= pix.width()+4) && (cHeight >= pix.height()+4) )
@@ -196,7 +196,7 @@ void RenderImage::printObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
                 if (aw>15 && ah>fm.height())
                     p->drawText(ax, ay, aw, ah , Qt::WordBreak, text );
             }
-#endif
+#endif /* APPLE_CHANGES not defined */
         }
     }
     else if (image && !image->isTransparent())
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_list.cpp b/WebCore/src/kdelibs/khtml/rendering/render_list.cpp
index 3429f88..2395081 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_list.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_list.cpp
@@ -246,13 +246,13 @@ void RenderListMarker::printObject(QPainter *p, int, int,
     p->setFont(style()->font());
     p->setPen(style()->color());
     QFontMetrics fm = p->fontMetrics();
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     // Why does khtml draw such large dots, squares, circle, etc for list items?
     // These seem much bigger than competing browsers.  I've reduced the size.
     int offset = fm.ascent()/3;
-#else
+#else /* APPLE_CHANGES not defined */
     int offset = fm.ascent()*2/3;
-#endif
+#endif /* APPLE_CHANGES not defined */
 
 #ifdef BOX_DEBUG
     p->setPen( QColor("red") );
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_style.h b/WebCore/src/kdelibs/khtml/rendering/render_style.h
index 40e352d..9c7e5b5 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_style.h
+++ b/WebCore/src/kdelibs/khtml/rendering/render_style.h
@@ -190,7 +190,9 @@ public:
     {
 	width = 3; // medium is default value
 	style = BNONE;
+#ifdef APPLE_CHANGES
 	color = Qt::black;
+#endif /* APPLE_CHANGES */
     }
     QColor color;
     unsigned short width : 12;
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_table.cpp b/WebCore/src/kdelibs/khtml/rendering/render_table.cpp
index 20fee35..3ee0061 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_table.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_table.cpp
@@ -729,8 +729,11 @@ void RenderTable::calcFinalColMax(int c, ColInfo* col)
         oldmin+=colMinWidth[o];
     }
 
+#ifdef APPLE_CHANGES
     // [kocienda] smin in unused
-    //int smin = col->min;
+#else /* APPLE_CHANGES not defined */
+    int smin = col->min;
+#endif /* APPLE_CHANGES not defined */
     int smax = col->max;
 
     if (col->type == Percent)
@@ -1358,8 +1361,12 @@ void RenderTable::layoutRows(int yoff)
                 continue;
             if ( c < totalCols - 1 && cell == cells[r][c+1] )
                 continue;
+#ifdef APPLE_CHANGES
             // [kocienda] fixed signed/unsigned comparison
             if ( (int)r < (int)totalRows - 1 && cell == cells[r+1][c] )
+#else /* APPLE_CHANGES not defined */
+            if ( r < (int)totalRows - 1 && cell == cells[r+1][c] )
+#endif /* APPLE_CHANGES not defined */
                 continue;
 
     	    cell->calcVerticalMargins();
@@ -1380,8 +1387,11 @@ void RenderTable::layoutRows(int yoff)
     else if (h.isPercent())
     {
         Length ch = containingBlock()->style()->height();
+#ifdef APPLE_CHANGES
         // [kocienda] containing is unused
-        //RenderObject *containing = containingBlock();
+#else /* APPLE_CHANGES not defined */
+        RenderObject *containing = containingBlock();
+#endif /* APPLE_CHANGES not defined */
         if (ch.isFixed())
             th = h.width(ch.value);
         else 
@@ -1428,8 +1438,12 @@ void RenderTable::layoutRows(int yoff)
                 continue;
             if ( c < totalCols - 1 && cell == cells[r][c+1] )
                 continue;
+#ifdef APPLE_CHANGES
             // [kocienda] fixed signed/unsigned comparison
             if ( (int)r < (int)totalRows - 1 && cell == cells[r+1][c] )
+#else /* APPLE_CHANGES not defined */
+            if ( r < (int)totalRows - 1 && cell == cells[r+1][c] )
+#endif /* APPLE_CHANGES not defined */
                 continue;
 
             if ( ( indx = c-cell->colSpan()+1 ) < 0 )
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_text.cpp b/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
index 149311c..f9ef877 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
@@ -107,30 +107,30 @@ void TextSlave::printDecoration( QPainter *pt, RenderText* p, int _tx, int _ty,
     int width = m_width;
 
     if( begin )
- 	    width -= p->paddingLeft() + p->borderLeft();
+ 	width -= p->paddingLeft() + p->borderLeft();
 
     if ( end )
         width -= p->paddingRight() + p->borderRight();
 
-
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     //int underlineOffset = pt->fontMetrics().baselineOffset() + 2;
-#else
+#else /* APPLE_CHANGES not defined */
     int underlineOffset = ( pt->fontMetrics().height() + m_baseline ) / 2;
     if(underlineOffset <= m_baseline) underlineOffset = m_baseline+1;
-#endif
+#endif /* APPLE_CHANGES not defined */
 
-    if(deco & UNDERLINE){
+    if(deco & UNDERLINE)
+#ifdef APPLE_CHANGES
+    {
         //fprintf (stderr, "UNDERLINE (%d, %d) to (%d, %d)\n", _tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
-#ifdef _KWQ_
         QConstString s(m_text, m_len);
         pt->drawUnderlineForText(_tx, _ty + m_baseline, s.string());
-#else
-        pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
-#endif
         //pt->drawLine(_tx, _ty, _tx + width, _ty );
         //pt->drawLine(_tx, _ty + pt->fontMetrics().height(), _tx + width, _ty + pt->fontMetrics().height() );
     }
+#else /* APPLE_CHANGES not defined */
+        pt->drawLine(_tx, _ty + underlineOffset, _tx + width, _ty + underlineOffset );
+#endif /* APPLE_CHANGES not defined */
     if(deco & OVERLINE)
         pt->drawLine(_tx, _ty, _tx + width, _ty );
     if(deco & LINE_THROUGH)
@@ -265,7 +265,11 @@ int TextSlaveArray::findFirstMatching(Item d) const
 	if ( (*this)[mid] == 0 )			// null item greater
 	    res = -1;
 	else
+#ifdef APPLE_CHANGES
 	    res = ((TextSlaveArray*)this)->compareItems( d, (*this)[mid] );
+#else /* APPLE_CHANGES not defined */
+	    res = ((QGVector*)this)->compareItems( d, (*this)[mid] );
+#endif /* APPLE_CHANGES not defined */
 	if ( res < 0 )
 	    n2 = mid - 1;
 	else if ( res > 0 )
@@ -278,7 +282,11 @@ int TextSlaveArray::findFirstMatching(Item d) const
     /* if ( !found )
 	return -1; */
     // search to first one equal or bigger
+#ifdef APPLE_CHANGES
     while ( found && (mid > 0) && !((TextSlaveArray*)this)->compareItems(d, (*this)[mid-1]) )
+#else /* APPLE_CHANGES not defined */
+    while ( found && (mid > 0) && !((QGVector*)this)->compareItems(d, (*this)[mid-1]) )
+#endif /* APPLE_CHANGES not defined */
 	mid--;
     return mid;
 }
@@ -638,8 +646,10 @@ void RenderText::printObject( QPainter *p, int /*x*/, int y, int /*w*/, int h,
 void RenderText::print( QPainter *p, int x, int y, int w, int h,
                       int tx, int ty)
 {
-    //if ( !isVisible() )
-    //    return;
+#ifndef APPLE_CHANGES
+    if ( !isVisible() )
+        return;
+#endif /* APPLE_CHANGES not defined */
 
     int s = m_lines.count() - 1;
     if ( s < 0 ) return;
diff --git a/WebCore/src/kdelibs/khtml/xml/dom_docimpl.cpp b/WebCore/src/kdelibs/khtml/xml/dom_docimpl.cpp
index d30f046..cf0b438 100644
--- a/WebCore/src/kdelibs/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/src/kdelibs/khtml/xml/dom_docimpl.cpp
@@ -78,7 +78,6 @@
 using namespace DOM;
 using namespace khtml;
 
-
 //template class QStack<DOM::NodeImpl>; // needed ?
 
 
@@ -586,11 +585,14 @@ void DocumentImpl::recalcStyle()
         float dpiY = 72.; // fallback
         if ( !khtml::printpainter )
             dpiY = paintDeviceMetrics()->logicalDpiY();
+#ifdef APPLE_CHANGES
         // FIXME: Is SCREEN_RESOLUTION hack good enough?
-        //if ( !khtml::printpainter && dpiY < 96 )
-        //    dpiY = 96.;
         if ( !khtml::printpainter && dpiY < SCREEN_RESOLUTION )
             dpiY = SCREEN_RESOLUTION;
+#else /* APPLE_CHANGES not defined */
+        if ( !khtml::printpainter && dpiY < 96 )
+            dpiY = 96.;
+#endif /* APPLE_CHANGES not defined */
         float size = fs[3] * dpiY / 72.;
         if(size < settings->minFontSize())
             size = settings->minFontSize();
diff --git a/WebCore/src/kdelibs/khtml/xml/dom_nodeimpl.cpp b/WebCore/src/kdelibs/khtml/xml/dom_nodeimpl.cpp
index a297ae4..32eecd5 100644
--- a/WebCore/src/kdelibs/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/src/kdelibs/khtml/xml/dom_nodeimpl.cpp
@@ -180,14 +180,13 @@ NodeImpl *NodeImpl::addChild(NodeImpl *)
   return 0;
 }
 
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
 khtml::RenderObject *NodeImpl::renderer() const
 {
     return m_render;
 }
-#endif
-
 
+#endif /* APPLE_CHANGES */
 QString NodeImpl::toHTML() const
 {
     NodeImpl* fc = firstChild();
diff --git a/WebCore/src/kdelibs/khtml/xml/dom_nodeimpl.h b/WebCore/src/kdelibs/khtml/xml/dom_nodeimpl.h
index 8f98b0c..d3bb215 100644
--- a/WebCore/src/kdelibs/khtml/xml/dom_nodeimpl.h
+++ b/WebCore/src/kdelibs/khtml/xml/dom_nodeimpl.h
@@ -193,11 +193,11 @@ public:
     virtual khtml::RenderStyle *style() const { return 0; }
 
     virtual void setRenderer(khtml::RenderObject *object) { m_render = object; }
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     khtml::RenderObject *renderer() const;
-#else
+#else /* APPLE_CHANGES not defined */
     virtual khtml::RenderObject *renderer() const { return m_render; }
-#endif
+#endif /* APPLE_CHANGES not defined */
 
 
     virtual DOM::CSSStyleDeclarationImpl *styleRules() { return 0; }
diff --git a/WebCore/src/kdelibs/khtml/xml/dom_stringimpl.cpp b/WebCore/src/kdelibs/khtml/xml/dom_stringimpl.cpp
index 6e39f88..55b716b 100644
--- a/WebCore/src/kdelibs/khtml/xml/dom_stringimpl.cpp
+++ b/WebCore/src/kdelibs/khtml/xml/dom_stringimpl.cpp
@@ -213,6 +213,9 @@ Length DOMStringImpl::toLength() const
 
 QList<Length> *DOMStringImpl::toLengthList() const
 {
+#ifndef APPLE_CHANGES
+    QString str(s, l);
+#endif /* APPLE_CHANGES not defined */
     int pos = 0;
     int pos2;
 
@@ -220,7 +223,7 @@ QList<Length> *DOMStringImpl::toLengthList() const
     // to fix lists like "1,2px 3 ,4"
     // make sure not to break percentage or relative widths
     // ### what about "auto" ?
-#ifdef _KWQ_
+#ifdef APPLE_CHANGES
     QChar spacified[l];
     QChar space(' ');
     for(unsigned int i=0; i < l; i++) {
@@ -233,16 +236,14 @@ QList<Length> *DOMStringImpl::toLengthList() const
         }
     }
     QString str(spacified, l);
-#else
-    QString str(s, l);
+#else /* APPLE_CHANGES not defined */
     QChar space(' ');
     for(unsigned int i=0; i < l; i++) {
         char cc = str[i].latin1();
-        if ( cc > '9' || ( cc < '0' && cc != '-' && cc != '*' && cc != '%' && cc != '.') ){
+        if ( cc > '9' || ( cc < '0' && cc != '-' && cc != '*' && cc != '%' && cc != '.') )
             str[i] = space;
-        }
     }
-#endif
+#endif /* APPLE_CHANGES not defined */
     str = str.simplifyWhiteSpace();
 
     QList<Length> *list = new QList<Length>;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list