see also rdar://4496964 Programatically change DOM styles via the Objective-C interface doesn't automatically update the display in the WebView. Consider the attached example. Build and run. Click the Change DOM button. The changes are not immediately visible. Mousing over the web view makes the change visible. Sending the webview a -setNeedsDisplay:YES or sending -setNeedsToApplyStyles:YES to the document view doesn't work around the problem either. The code which manipulates the DOM looks like this: DOMDocument *document = [[webView mainFrame] DOMDocument]; DOMElement *element = [document getElementById: @"foo"]; DOMCSSStyleDeclaration *style = [element style]; [style setBackground :@"red"];
Created attachment 7405 [details] Example app
Confirming the behavior, though i don't know for sure if this is wrong :)
This still happens. Using setValue:forKey: is a workaround, because that causes the change to happen in the JavaScript binding (which always does an update layout and paints if needed). It seems we should do something similar on the ObjC binding side, or make WebCore smarter about when to update automatically.
rniwa@webkit.org - Is this need anymore? Thanks!
We're not improving legacy webkit API at this point.