1
2
3
4
5
6
7
|
bool DOMImplementation::isXMLMIMEType(
const
String& mimeType) {
if
(mimeType ==
"text/xml"
|| mimeType ==
"application/xml"
|| mimeType ==
"text/xsl"
)
return
true
;
static
const
char
*
const
validChars =
"[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]"
;
// per RFCs: 3023, 2045
DEFINE_STATIC_LOCAL(RegularExpression, xmlTypeRegExp, (String(
"^"
) + validChars +
"+/"
+ validChars +
"+\\+xml$"
, TextCaseSensitive));
return
xmlTypeRegExp.match(mimeType) > -
1
;
}
|
1
|
If(mimeType == “text/vnd.wap.wml”)
return
true
;
|
1
2
3
4
5
6
7
8
9
|
// Does the header parsing work on the WebCore thread.
private
void
handleHeaders(Headers headers) {
…
}
else
if
(mMimeType.equals(
"text/vnd.wap.wml"
)) {
// As we don't support wml, render it as plain text
mMimeType =
"text/plain"
;
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
void
WMLAElement::defaultEventHandler(Event* event) {
if
(isLink() && (event->type() == eventNames().clickEvent || (event->type() == eventNames().keydownEvent && focused()))) {
MouseEvent* e =
0
;
if
(event->type() == eventNames().clickEvent && event->isMouseEvent())
e = static_cast<MouseEvent*>(event);
KeyboardEvent* k =
0
;
if
(event->type() == eventNames().keydownEvent && event->isKeyboardEvent())
k = static_cast<KeyboardEvent*>(event);
if
(e && e->button() == RightButton) {
WMLElement::defaultEventHandler(event);
return
;
}
if
(k) {
if
(k->keyIdentifier() !=
"Enter"
) {
WMLElement::defaultEventHandler(event);
return
;
}
event->setDefaultHandled();
dispatchSimulatedClick(event);
return
;
}
if
(!event->defaultPrevented() && document()->frame()) {
String url = document()->completeURL(deprecatedParseURL(getAttribute(HTMLNames::hrefAttr)));
/
document()->frame()->loader()->urlSelected(url, target(), event,
false
,
false
,
true
, SendReferrer);
}
event->setDefaultHandled();
}
}
|
1
2
3
4
5
6
|
if
(!event->defaultPrevented() && document()->frame()) {
// Substitute variables within target url attribute value. String href = getAttribute(HTMLNames::hrefAttr);
href = substituteVariableReferences(href, document(), WMLVariableEscapingEscape);
String url = document()->completeURL(deprecatedParseURL(href));
document()->frame()->loader()->urlSelected(url, target(), event,
false
,
false
,
true
, SendReferrer);
}
|
1
2
3
4
5
6
|
KURL WMLAElement::href()
const
{
// Substitute variables within target url attribute value.
String href = substituteVariableReferences(getAttribute(HTMLNames::hrefAttr),
document(), WMLVariableEscapingEscape);
return
document()->completeURL(href);
}
|
1
2
3
4
|
WebCore::String WebViewCore::retrieveHref(WebCore::Frame* frame, WebCore::Node* node) {
WebCore::HTMLAnchorElement* anchor = retrieveAnchorElement(frame, node);
return
anchor ? anchor->href() : WebCore::String();
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/**add WML anchor support. 20110224, begin**/
#
if
ENABLE(WML)
WebCore::WMLAnchorElement* WebViewCore::retrieveWMLAElement(WebCore::Frame* frame, WebCore::Node* node) {
if
(!CacheBuilder::validNode(m_mainFrame, frame, node))
return
0
;
if
(!node->hasTagName(WebCore::WMLNames::aTag))
return
0
;
return
static_cast<WebCore::WMLAnchorElement*>(node);
}
#endif
/**add WML anchor support 20110224, end**/
WebCore::String WebViewCore::retrieveHref(WebCore::Frame* frame, WebCore::Node* node) {
/**retrieve WMLAnchor element. 20110224, begin**/
#
if
ENABLE(WML)
if
(node->isWMLElement()) {
WebCore::WMLAnchorElement* anchor = retrieveWMLAElement(frame, node);
return
anchor ? anchor->href() : WebCore::String();
}
#endif
/**retrieve WMLAnchor element. 20110224, end**/
WebCore::HTMLAnchorElement* anchor = retrieveAnchorElement(frame, node);
return
anchor ? anchor->href() : WebCore::String();
}
|
1
2
3
4
5
6
7
8
9
10
11
12
|
WebCore::String WebViewCore::retrieveAnchorText(WebCore::Frame* frame, WebCore::Node* node) {
/**retrieve WMLAnchor element. 20110224, begin**/
#
if
ENABLE(WML)
if
(node->isWMLElement()) {
WebCore::WMLAnchorElement* anchor = retrieveWMLAElement(frame, node);
return
anchor ? anchor->title() : WebCore::String();
}
#endif
/**retrieve WMLAnchor element. 20110224, end**/
WebCore::HTMLAnchorElement* anchor = retrieveAnchorElement(frame, node);
return
anchor ? anchor->text() : WebCore::String();
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Does the header parsing work on the WebCore thread.
private
void
handleHeaders(Headers headers) {
。。。
String contentType = headers.getContentType();
if
(contentType !=
null
) {
parseContentTypeHeader(contentType);
// If we have one of "generic" MIME types, try to deduce
// the right MIME type from the file extension (if any):
if
(mMimeType.equals(
"text/plain"
) ||
mMimeType.equals(
"application/octet-stream"
)) {
// for attachment, use the filename in the Content-Disposition
// to guess the mimetype
String contentDisposition = headers.getContentDisposition();
String url =
null
;
if
(contentDisposition !=
null
) {
url = URLUtil.parseContentDisposition(contentDisposition);
}
if
(url ==
null
) {
url = mUrl;
}
String newMimeType = guessMimeTypeFromExtension(url);
if
(newMimeType !=
null
) {
mMimeType = newMimeType;
}
}
else
if
(mMimeType.equals(
"text/vnd.wap.wml"
)) {
// As we don't support wml, render it as plain text
// mMimeType = "text/plain";
}
else
{
// It seems that xhtml+xml and vnd.wap.xhtml+xml mime
// subtypes are used interchangeably. So treat them the same.
//if (mMimeType.equals("application/vnd.wap.xhtml+xml")) {
// mMimeType = "application/xhtml+xml";
//}
/* Webkit used libxml2 as the xml parser, but the CMCC's WAP sites
written in WML or XHTML do not meet W3C's specification well,
and libxml2 will throw a lot of grammatical errors when it parses
the document which has the mime type is "application/xhtml+xml" or
"application/vnd.wap.xhtml+xml". When i opened the macro named
"XHTMLMP" in config.h in webcore and tested, i found some bugs,
i believed that Google did not do detail test works for this macro.
So i could handle "XHTML" mime type as "HTML" only in order to
open CMCC's WAP sites in browser.
*/
if
(mMimeType.equals(
"application/vnd.wap.xhtml+xml"
) ||
mMimeType.equals(
"application/xhtml+xml"
)) {
mMimeType =
"text/html"
;
}
}
}
}
|