Re: [webkit-dev] getting contents of noscript element through DOM

2009-10-26 Thread Darin Adler

On Oct 12, 2009, at 9:30 AM, mab2001 wrote:

It seems that with WebKit, the contents of the noscript tag cannot  
be accessed through the DOM. FF and IE (haven't tested other  
browsers) allow access through the textContent property but in  
Safari and Chrome this just comes back blank.


I think this is simply a mistake, not something intentional in a  
thoughtful way.


It’s the HTML parser that’s doing the discarding of the content here.  
Changing the parser to instead create a text node seems relatively  
straightforward, although not trivial.


I've tried looking through the WebKit code to see why this is  
happening but admit to being a little lost.


The code in question is in the file HTMLParser.cpp. The content is  
skipped by calls to the function setSkipMode. The code that actually  
causes the content to be discarded is the code that calls the skipMode 
() function in HTMLParser.cpp and HTMLTokenizer.cpp. There are six  
different call sites.


If we change noscript, we probably want to do the same thing for  
noembed and noframes.


One of the most important aspects of fixing this bug would be to  
create some good test cases. Even someone who will not fix the bug  
could create the bug in bugs.webkit.org and make test cases, try the  
test cases out in other browsers and make sure they pass. That person  
could even make the test cases in the proper form for the LayoutTests  
directory and submit a patch with the test case and the current  
expected failures as a way to get the ball rolling.


-- Darin

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] getting contents of noscript element through DOM

2009-10-26 Thread Maciej Stachowiak


On Oct 26, 2009, at 12:40 AM, Darin Adler wrote:


On Oct 12, 2009, at 9:30 AM, mab2001 wrote:

It seems that with WebKit, the contents of the noscript tag cannot  
be accessed through the DOM. FF and IE (haven't tested other  
browsers) allow access through the textContent property but in  
Safari and Chrome this just comes back blank.


I think this is simply a mistake, not something intentional in a  
thoughtful way.


It’s the HTML parser that’s doing the discarding of the content  
here. Changing the parser to instead create a text node seems  
relatively straightforward, although not trivial.


I've tried looking through the WebKit code to see why this is  
happening but admit to being a little lost.


The code in question is in the file HTMLParser.cpp. The content is  
skipped by calls to the function setSkipMode. The code that actually  
causes the content to be discarded is the code that calls the  
skipMode() function in HTMLParser.cpp and HTMLTokenizer.cpp. There  
are six different call sites.


If we change noscript, we probably want to do the same thing for  
noembed and noframes.


One of the most important aspects of fixing this bug would be to  
create some good test cases. Even someone who will not fix the bug  
could create the bug in bugs.webkit.org and make test cases, try the  
test cases out in other browsers and make sure they pass. That  
person could even make the test cases in the proper form for the  
LayoutTests directory and submit a patch with the test case and the  
current expected failures as a way to get the ball rolling.


I'd suggest checking whether any of the HTML5 parsing libraries have  
noscript tests in their test suites. In general our goal for the  
parser should be to converge towards HTML5 behavior.


 - Maciej

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] getting contents of noscript element through DOM

2009-10-17 Thread mab2001

Hi,

It seems that with webkit, the contents of the noscript tag cannot be
accessed through the DOM. FF and IE (haven't tested other browsers) allow
access through the textContent property but in Safari and Chrome this just
comes back blank. I've tried looking through the WebKit code to see why this
is happening but admit to being a little lost.

So my question is, is there a way to access the content of a noscript tag
through JavaScript? If not, would an enhancement request to allow this be
met favorably?

Here's the particular use case I am working on. A common technique when
embedding Flash in an HTML page is to first place an alternate content div
inside the HTML and then to replace that div with the Flash movie if it's
determined that the browser has JavaScript enabled and a high enough version
of the Flash player installed.

The problem with this approach is that heavy alternate content can hurt
performance even when it is not needed. For example, if it contains images,
those images will be put in the browser's load queue before the Flash movie.
So even though the image elements are removed from the DOM and replaced with
an embedded Flash movie, those images must still load prior to the browser
loading the Flash movie. (If anyone knows how to remove an image from the
load queue that might also be helpful.)

An approach to solving this problem that I have been trying has been to
place the alternate contents in a noscript tag. If the browser has
JavaScript disabled then the alternate content is shown. And if the browser
has JavaScript enabled but an older version of Flash installed, I basically
replace the noscript element with its contents rendered as HTML. When this
approach works, it's great because the alternate content HTML and images are
only parsed and added to the loader queue if needed.

Hopefully this use case is reasonable enough to sway anyone away from saying
the noscript tag should act as a impenetrable barrier between a browser with
JavaScript enabled and one without.

Thanks,
Mike
-- 
View this message in context: 
http://www.nabble.com/getting-contents-of-noscript-element-through-DOM-tp25858906p25858906.html
Sent from the Webkit mailing list archive at Nabble.com.

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev