Lines 55-62
inline HTMLLinkElement::HTMLLinkElement(const QualifiedName& tagName, Document*
Link Here
|
55 |
: HTMLElement(tagName, document) |
55 |
: HTMLElement(tagName, document) |
56 |
, m_linkLoader(this) |
56 |
, m_linkLoader(this) |
57 |
, m_sizes(DOMSettableTokenList::create()) |
57 |
, m_sizes(DOMSettableTokenList::create()) |
|
|
58 |
, m_disabledState(Unset) |
58 |
, m_loading(false) |
59 |
, m_loading(false) |
59 |
, m_isEnabledViaScript(false) |
|
|
60 |
, m_createdByParser(createdByParser) |
60 |
, m_createdByParser(createdByParser) |
61 |
, m_isInShadowTree(false) |
61 |
, m_isInShadowTree(false) |
62 |
, m_pendingSheetType(None) |
62 |
, m_pendingSheetType(None) |
Lines 80-122
HTMLLinkElement::~HTMLLinkElement()
Link Here
|
80 |
} |
80 |
} |
81 |
} |
81 |
} |
82 |
|
82 |
|
83 |
void HTMLLinkElement::setDisabled(bool disabled) |
83 |
void HTMLLinkElement::setDisabledState(bool disabled) |
84 |
{ |
84 |
{ |
85 |
if (!m_sheet) |
85 |
DisabledState oldDisabledState = m_disabledState; |
86 |
return; |
86 |
m_disabledState = disabled ? Disabled : EnabledViaScript; |
87 |
|
87 |
if (oldDisabledState != m_disabledState) { |
88 |
bool wasDisabled = m_sheet->disabled(); |
88 |
// If we change the disabled state while the sheet is still loading, then we have to |
89 |
if (wasDisabled == disabled) |
89 |
// perform three checks: |
90 |
return; |
90 |
if (isLoading()) { |
91 |
|
91 |
// Check #1: The sheet becomes disabled while loading. |
92 |
m_sheet->setDisabled(disabled); |
92 |
if (m_disabledState == Disabled) |
93 |
m_isEnabledViaScript = !disabled; |
93 |
removePendingSheet(); |
94 |
|
94 |
|
95 |
// If we change the disabled state while the sheet is still loading, then we have to |
95 |
// Check #2: An alternate sheet becomes enabled while it is still loading. |
96 |
// perform three checks: |
96 |
if (m_relAttribute.m_isAlternate && m_disabledState == EnabledViaScript) |
97 |
if (isLoading()) { |
97 |
addPendingSheet(Blocking); |
98 |
// Check #1: The sheet becomes disabled while loading. |
98 |
|
99 |
if (disabled) |
99 |
// Check #3: A main sheet becomes enabled while it was still loading and |
100 |
removePendingSheet(); |
100 |
// after it was disabled via script. It takes really terrible code to make this |
101 |
|
101 |
// happen (a double toggle for no reason essentially). This happens on |
102 |
// Check #2: An alternate sheet becomes enabled while it is still loading. |
102 |
// virtualplastic.net, which manages to do about 12 enable/disables on only 3 |
103 |
if (m_relAttribute.m_isAlternate && !disabled) |
103 |
// sheets. :) |
104 |
addPendingSheet(Blocking); |
104 |
if (!m_relAttribute.m_isAlternate && m_disabledState == EnabledViaScript && oldDisabledState == Disabled) |
105 |
|
105 |
addPendingSheet(Blocking); |
106 |
// Check #3: A main sheet becomes enabled while it was still loading and |
106 |
|
107 |
// after it was disabled via script. It takes really terrible code to make this |
107 |
// If the sheet is already loading just bail. |
108 |
// happen (a double toggle for no reason essentially). This happens on |
108 |
return; |
109 |
// virtualplastic.net, which manages to do about 12 enable/disables on only 3 |
109 |
} |
110 |
// sheets. :) |
|
|
111 |
if (!m_relAttribute.m_isAlternate && !disabled && wasDisabled) |
112 |
addPendingSheet(Blocking); |
113 |
|
110 |
|
114 |
// If the sheet is already loading just bail. |
111 |
// Load the sheet, since it's never been loaded before. |
115 |
return; |
112 |
if (!m_sheet && m_disabledState == EnabledViaScript) |
|
|
113 |
process(); |
114 |
else |
115 |
document()->styleSelectorChanged(DeferRecalcStyle); // Update the style selector. |
116 |
} |
116 |
} |
117 |
|
|
|
118 |
if (!disabled) |
119 |
process(); |
120 |
} |
117 |
} |
121 |
|
118 |
|
122 |
StyleSheet* HTMLLinkElement::sheet() const |
119 |
StyleSheet* HTMLLinkElement::sheet() const |
Lines 141-147
void HTMLLinkElement::parseMappedAttribute(Attribute* attr)
Link Here
|
141 |
} else if (attr->name() == mediaAttr) { |
138 |
} else if (attr->name() == mediaAttr) { |
142 |
m_media = attr->value().string().lower(); |
139 |
m_media = attr->value().string().lower(); |
143 |
process(); |
140 |
process(); |
144 |
} else if (attr->name() == onbeforeloadAttr) |
141 |
} else if (attr->name() == disabledAttr) |
|
|
142 |
setDisabledState(!attr->isNull()); |
143 |
else if (attr->name() == onbeforeloadAttr) |
145 |
setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr)); |
144 |
setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr)); |
146 |
#if ENABLE(LINK_PREFETCH) |
145 |
#if ENABLE(LINK_PREFETCH) |
147 |
else if (attr->name() == onloadAttr) |
146 |
else if (attr->name() == onloadAttr) |
Lines 181-187
void HTMLLinkElement::process()
Link Here
|
181 |
|
180 |
|
182 |
bool acceptIfTypeContainsTextCSS = document()->page() && document()->page()->settings() && document()->page()->settings()->treatsAnyTextCSSLinkAsStylesheet(); |
181 |
bool acceptIfTypeContainsTextCSS = document()->page() && document()->page()->settings() && document()->page()->settings()->treatsAnyTextCSSLinkAsStylesheet(); |
183 |
|
182 |
|
184 |
if (!disabled() && (m_relAttribute.m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css"))) |
183 |
if (m_disabledState != Disabled && (m_relAttribute.m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css"))) |
185 |
&& document()->frame() && m_url.isValid()) { |
184 |
&& document()->frame() && m_url.isValid()) { |
186 |
|
185 |
|
187 |
String charset = getAttribute(charsetAttr); |
186 |
String charset = getAttribute(charsetAttr); |
Lines 440-450
void HTMLLinkElement::removePendingSheet()
Link Here
|
440 |
document()->removePendingSheet(); |
439 |
document()->removePendingSheet(); |
441 |
} |
440 |
} |
442 |
|
441 |
|
443 |
bool HTMLLinkElement::disabled() const |
|
|
444 |
{ |
445 |
return m_sheet && m_sheet->disabled(); |
446 |
} |
447 |
|
448 |
DOMSettableTokenList* HTMLLinkElement::sizes() const |
442 |
DOMSettableTokenList* HTMLLinkElement::sizes() const |
449 |
{ |
443 |
{ |
450 |
return m_sizes.get(); |
444 |
return m_sizes.get(); |