- fixed problem where our updateLayout call ignores pending stylesheets all the time
* khtml/xml/dom_docimpl.h: Added updateLayoutIgnorePendingStylesheets.
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::updateLayout): Took out the "ignore pending stylesheets" business here.
(DocumentImpl::updateLayoutIgnorePendingStylesheets): Put it in here.
* khtml/ecma/kjs_dom.cpp: (DOMNode::getValueProperty): Call the new
updateLayoutIgnorePendingStylesheets function.
* khtml/ecma/kjs_html.cpp:
(KJS::HTMLElement::getValueProperty): Ditto.
(KJS::HTMLElement::putValue): Ditto.
* khtml/ecma/kjs_views.cpp: (DOMAbstractViewFunc::tryCall): Ditto.
* khtml/ecma/kjs_window.cpp:
(Window::updateLayout): Ditto.
(Selection::get): Ditto.
(SelectionFunc::tryCall): Ditto.
* khtml/html/html_imageimpl.h: Add ignorePendingStylesheets boolean parameter.
* khtml/html/html_imageimpl.cpp:
(HTMLImageElementImpl::width): Respect new parameter.
(HTMLImageElementImpl::height): Ditto.
- tweaks
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge alterCurrentSelection:direction:granularity:]): Removed unneeded
explicit "true" parameter to setSelection.
(-[WebCoreBridge alterCurrentSelection:verticalDistance:]): Ditto.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7625
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-09-21 Darin Adler <darin@apple.com>
+
+ Reviewed by Ken.
+
+ - fixed problem where our updateLayout call ignores pending stylesheets all the time
+
+ * khtml/xml/dom_docimpl.h: Added updateLayoutIgnorePendingStylesheets.
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::updateLayout): Took out the "ignore pending stylesheets" business here.
+ (DocumentImpl::updateLayoutIgnorePendingStylesheets): Put it in here.
+
+ * khtml/ecma/kjs_dom.cpp: (DOMNode::getValueProperty): Call the new
+ updateLayoutIgnorePendingStylesheets function.
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::HTMLElement::getValueProperty): Ditto.
+ (KJS::HTMLElement::putValue): Ditto.
+ * khtml/ecma/kjs_views.cpp: (DOMAbstractViewFunc::tryCall): Ditto.
+ * khtml/ecma/kjs_window.cpp:
+ (Window::updateLayout): Ditto.
+ (Selection::get): Ditto.
+ (SelectionFunc::tryCall): Ditto.
+
+ * khtml/html/html_imageimpl.h: Add ignorePendingStylesheets boolean parameter.
+ * khtml/html/html_imageimpl.cpp:
+ (HTMLImageElementImpl::width): Respect new parameter.
+ (HTMLImageElementImpl::height): Ditto.
+
+ - tweaks
+
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge alterCurrentSelection:direction:granularity:]): Removed unneeded
+ explicit "true" parameter to setSelection.
+ (-[WebCoreBridge alterCurrentSelection:verticalDistance:]): Ditto.
+
2004-09-21 Darin Adler <darin@apple.com>
Reviewed by Ken.
// Make sure our layout is up to date before we allow a query on these attributes.
DOM::DocumentImpl* docimpl = node.handle()->getDocument();
if (docimpl) {
- docimpl->updateLayout();
+ docimpl->updateLayoutIgnorePendingStylesheets();
}
khtml::RenderObject *rend = node.handle()->renderer();
// Update the document's layout before we compute these attributes.
DOM::DocumentImpl* docimpl = node.handle()->getDocument();
if (docimpl) {
- docimpl->updateLayout();
+ docimpl->updateLayoutIgnorePendingStylesheets();
}
switch (token) {
case BodyScrollLeft:
case AnchorShape: return String(anchor.shape());
case AnchorTabIndex: return Number(anchor.tabIndex());
case AnchorTarget: return String(anchor.target());
- case AnchorText: return String(anchor.innerText());
case AnchorType: return String(anchor.type());
+ case AnchorText: {
+ DOM::DocumentImpl* docimpl = node.handle()->getDocument();
+ if (docimpl) {
+ docimpl->updateLayoutIgnorePendingStylesheets();
+ }
+ }
+ return String(anchor.innerText());
}
}
break;
case ImageAlign: return String(image.align());
case ImageAlt: return String(image.alt());
case ImageBorder: return Number(image.border());
- case ImageHeight: return Number(image.height());
+ case ImageHeight: return Number(static_cast<DOM::HTMLImageElementImpl *>(image.handle())->height(true));
case ImageHspace: return Number(image.hspace());
case ImageIsMap: return Boolean(image.isMap());
case ImageLongDesc: return String(image.longDesc());
case ImageSrc: return String(image.src());
case ImageUseMap: return String(image.useMap());
case ImageVspace: return Number(image.vspace());
- case ImageWidth: return Number(image.width());
+ case ImageWidth: return Number(static_cast<DOM::HTMLImageElementImpl *>(image.handle())->width(true));
case ImageX: return Number(image.x());
case ImageY: return Number(image.y());
}
case ElementInnerHTML:
return String(element.innerHTML());
case ElementInnerText:
+ {
+ DOM::DocumentImpl* docimpl = node.handle()->getDocument();
+ if (docimpl) {
+ docimpl->updateLayoutIgnorePendingStylesheets();
+ }
+ }
return String(element.innerText());
case ElementOuterHTML:
return String(element.outerHTML());
// Update the document's layout before we compute these attributes.
DOM::DocumentImpl* docimpl = body.handle()->getDocument();
if (docimpl)
- docimpl->updateLayout();
+ docimpl->updateLayoutIgnorePendingStylesheets();
if (token == BodyScrollLeft)
sview->setContentsPos(value.toInt32(exec), sview->contentsY());
else
/*
* This file is part of the KDE libraries
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
+ * Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "ecma/kjs_views.lut.h"
#include "ecma/kjs_css.h"
+#include "xml/dom_docimpl.h"
+
using namespace KJS;
// -------------------------------------------------------------------------
DOM::Node arg0 = toNode(args[0]);
if (arg0.nodeType() != DOM::Node::ELEMENT_NODE)
return Undefined(); // throw exception?
- else
+ else {
+ DOM::DocumentImpl* docimpl = arg0.handle()->getDocument();
+ if (docimpl) {
+ docimpl->updateLayoutIgnorePendingStylesheets();
+ }
return getDOMCSSStyleDeclaration(exec,abstractView.getComputedStyle(static_cast<DOM::Element>(arg0),
args[1].toString(exec).string()));
+ }
}
}
return Undefined();
{
DOM::DocumentImpl* docimpl = static_cast<DOM::DocumentImpl *>(m_part->document().handle());
if (docimpl) {
- docimpl->updateLayout();
+ docimpl->updateLayoutIgnorePendingStylesheets();
}
}
DocumentImpl *docimpl = m_part->xmlDocImpl();
if (docimpl)
- docimpl->updateLayout();
+ docimpl->updateLayoutIgnorePendingStylesheets();
KURL url = m_part->url();
const HashEntry *entry = Lookup::findEntry(&SelectionTable, p);
if (part) {
DocumentImpl *docimpl = part->xmlDocImpl();
if (docimpl)
- docimpl->updateLayout();
+ docimpl->updateLayoutIgnorePendingStylesheets();
switch (id) {
case Selection::Collapse:
HTMLElementImpl::detach();
}
-long HTMLImageElementImpl::width() const
+long HTMLImageElementImpl::width(bool ignorePendingStylesheets) const
{
if (!m_render) {
// check the attribute first for an explicit pixel value
DOM::DocumentImpl* docimpl = getDocument();
if (docimpl) {
- docimpl->updateLayout();
+ if (ignorePendingStylesheets)
+ docimpl->updateLayoutIgnorePendingStylesheets();
+ else
+ docimpl->updateLayout();
}
if (!m_render) {
return m_render->contentWidth();
}
-long HTMLImageElementImpl::height() const
+long HTMLImageElementImpl::height(bool ignorePendingStylesheets) const
{
if (!m_render) {
// check the attribute first for an explicit pixel value
DOM::DocumentImpl* docimpl = getDocument();
if (docimpl) {
- docimpl->updateLayout();
+ if (ignorePendingStylesheets)
+ docimpl->updateLayoutIgnorePendingStylesheets();
+ else
+ docimpl->updateLayout();
}
if (!m_render) {
virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
virtual void detach();
- long width() const;
- long height() const;
+ long width(bool ignorePendingStylesheets = false) const;
+ long height(bool ignorePendingStylesheets = false) const;
bool isServerMap() const { return ( ismap && !usemap.length() ); }
QImage currentImage() const;
}
void DocumentImpl::updateLayout()
+{
+ // FIXME: Dave's pretty sure we can remove this because
+ // layout calls recalcStyle as needed.
+ updateRendering();
+
+ // Only do a layout if changes have occurred that make it necessary.
+ if (m_view && renderer() && renderer()->needsLayout())
+ m_view->layout();
+}
+
+// FIXME: This is a bad idea and needs to be removed eventually.
+// Other browsers load stylesheets before they continue parsing the web page.
+// Since we don't, we can run JavaScript code that needs answers before the
+// stylesheets are loaded. Doing a layout ignoring the pending stylesheets
+// lets us get reasonable answers. The long term solution to this problem is
+// to instead suspend JavaScript execution.
+void DocumentImpl::updateLayoutIgnorePendingStylesheets()
{
bool oldIgnore = m_ignorePendingStylesheets;
updateStyleSelector();
}
- updateRendering();
-
- // Only do a layout if changes have occurred that make it necessary.
- if (m_view && renderer() && renderer()->needsLayout()) {
- m_view->layout();
- }
+ updateLayout();
m_ignorePendingStylesheets = oldIgnore;
}
static QPtrList<DocumentImpl> * changedDocuments;
virtual void updateRendering();
void updateLayout();
+ void updateLayoutIgnorePendingStylesheets();
static void updateDocumentsRendering();
khtml::DocLoader *docLoader() { return m_docLoader; }
xPos = _part->xPosForVerticalArrowNavigation();
// setting the selection always clears saved vertical navigation x position
- _part->setSelection(selection, true);
+ _part->setSelection(selection);
// restore vertical navigation x position if necessary
if (xPos != KHTMLPart::NoXPosForVerticalArrowNavigation)
// setting the selection always clears saved vertical navigation x position, so preserve it
int xPos = _part->xPosForVerticalArrowNavigation();
- _part->setSelection(selection, true);
+ _part->setSelection(selection);
_part->setXPosForVerticalArrowNavigation(xPos);
[self ensureCaretVisible];