Lines 56-62
inline HTMLLinkElement::HTMLLinkElement(const QualifiedName& tagName, Document*
Link Here
|
56 |
, m_linkLoader(this) |
56 |
, m_linkLoader(this) |
57 |
, m_sizes(DOMSettableTokenList::create()) |
57 |
, m_sizes(DOMSettableTokenList::create()) |
58 |
, m_loading(false) |
58 |
, m_loading(false) |
59 |
, m_isEnabledViaScript(false) |
59 |
, m_isEnabledViaScript(Unset) |
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 82-96
HTMLLinkElement::~HTMLLinkElement()
Link Here
|
82 |
|
82 |
|
83 |
void HTMLLinkElement::setDisabled(bool disabled) |
83 |
void HTMLLinkElement::setDisabled(bool disabled) |
84 |
{ |
84 |
{ |
85 |
if (!m_sheet) |
85 |
if (!m_sheet) { |
|
|
86 |
// If we are in the middle of loading a stylesheet, we store the information from this call |
87 |
// as it is a common pattern to disable / enable the stylesheet through JS (regardless of |
88 |
// whether the sheet was loaded). |
89 |
// See https://bugs.webkit.org/show_bug.cgi?id=65140 |
90 |
if (m_relAttribute.m_isStyleSheet && m_loading) |
91 |
setEnabledViaScript(!disabled); |
86 |
return; |
92 |
return; |
|
|
93 |
} |
87 |
|
94 |
|
88 |
bool wasDisabled = m_sheet->disabled(); |
95 |
bool wasDisabled = m_sheet->disabled(); |
89 |
if (wasDisabled == disabled) |
96 |
|
|
|
97 |
if (wasDisabled == disabled) { |
98 |
// If JS forces the sheet to be enabled, we need to force a recalcStyleSelector or |
99 |
// we may not apply the stylesheet (for example for alternate stylesheet). |
100 |
if (isEnabledViaScript() != !disabled) { |
101 |
setEnabledViaScript(!disabled); |
102 |
document()->styleSelectorChanged(DeferRecalcStyle); |
103 |
} |
90 |
return; |
104 |
return; |
|
|
105 |
} |
91 |
|
106 |
|
|
|
107 |
setEnabledViaScript(!disabled); |
92 |
m_sheet->setDisabled(disabled); |
108 |
m_sheet->setDisabled(disabled); |
93 |
m_isEnabledViaScript = !disabled; |
|
|
94 |
|
109 |
|
95 |
// If we change the disabled state while the sheet is still loading, then we have to |
110 |
// If we change the disabled state while the sheet is still loading, then we have to |
96 |
// perform three checks: |
111 |
// perform three checks: |
Lines 117-122
void HTMLLinkElement::setDisabled(bool disabled)
Link Here
|
117 |
|
132 |
|
118 |
if (!disabled) |
133 |
if (!disabled) |
119 |
process(); |
134 |
process(); |
|
|
135 |
|
136 |
checkDisabledAndEnabledViaScriptState(); |
120 |
} |
137 |
} |
121 |
|
138 |
|
122 |
StyleSheet* HTMLLinkElement::sheet() const |
139 |
StyleSheet* HTMLLinkElement::sheet() const |
Lines 356-365
void HTMLLinkElement::linkLoadingErrored()
Link Here
|
356 |
|
373 |
|
357 |
bool HTMLLinkElement::sheetLoaded() |
374 |
bool HTMLLinkElement::sheetLoaded() |
358 |
{ |
375 |
{ |
|
|
376 |
// Migrate the disabled information before removePendingSheet is called |
377 |
// as it will start a recalStyleSelector which needs this information. |
378 |
if (m_isEnabledViaScript != Unset) { |
379 |
ASSERT(!m_loading); |
380 |
ASSERT(m_relAttribute.m_isStyleSheet); |
381 |
setDisabled(m_isEnabledViaScript == Disabled); |
382 |
} |
383 |
|
359 |
if (!isLoading()) { |
384 |
if (!isLoading()) { |
360 |
removePendingSheet(); |
385 |
removePendingSheet(); |
361 |
return true; |
386 |
return true; |
362 |
} |
387 |
} |
|
|
388 |
|
363 |
return false; |
389 |
return false; |
364 |
} |
390 |
} |
365 |
|
391 |
|
Lines 442-448
void HTMLLinkElement::removePendingSheet()
Link Here
|
442 |
|
468 |
|
443 |
bool HTMLLinkElement::disabled() const |
469 |
bool HTMLLinkElement::disabled() const |
444 |
{ |
470 |
{ |
445 |
return m_sheet && m_sheet->disabled(); |
471 |
checkDisabledAndEnabledViaScriptState(); |
|
|
472 |
|
473 |
if (m_sheet) |
474 |
return m_sheet->disabled(); |
475 |
|
476 |
// FF disagrees with the spec and always has an associated stylesheet if the 'rel' attribute indicates a |
477 |
// stylesheet and href is provided (regardless of whether the resource may be in error). As we store the |
478 |
// enabled state in m_isEnabledViaScript while loading, return this information to be consistent with FF |
479 |
// and our future self here. |
480 |
if (isLoading() && m_isEnabledViaScript != Unset) |
481 |
return m_isEnabledViaScript == Disabled; |
482 |
|
483 |
return false; |
446 |
} |
484 |
} |
447 |
|
485 |
|
448 |
DOMSettableTokenList* HTMLLinkElement::sizes() const |
486 |
DOMSettableTokenList* HTMLLinkElement::sizes() const |