| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
| 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
| 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 #include "core/inspector/InspectorCSSAgent.h" | 26 #include "core/inspector/InspectorCSSAgent.h" |
| 27 | 27 |
| 28 #include "CSSPropertyNames.h" | 28 #include "CSSPropertyNames.h" |
| 29 #include "FetchInitiatorTypeNames.h" | |
| 30 #include "InspectorTypeBuilder.h" | 29 #include "InspectorTypeBuilder.h" |
| 31 #include "StylePropertyShorthand.h" | 30 #include "StylePropertyShorthand.h" |
| 32 #include "bindings/v8/ExceptionState.h" | 31 #include "bindings/v8/ExceptionState.h" |
| 33 #include "bindings/v8/ExceptionStatePlaceholder.h" | 32 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 34 #include "core/css/CSSComputedStyleDeclaration.h" | 33 #include "core/css/CSSComputedStyleDeclaration.h" |
| 35 #include "core/css/CSSDefaultStyleSheets.h" | 34 #include "core/css/CSSDefaultStyleSheets.h" |
| 36 #include "core/css/CSSImportRule.h" | 35 #include "core/css/CSSImportRule.h" |
| 37 #include "core/css/CSSMediaRule.h" | 36 #include "core/css/CSSMediaRule.h" |
| 38 #include "core/css/CSSRule.h" | 37 #include "core/css/CSSRule.h" |
| 39 #include "core/css/CSSRuleList.h" | 38 #include "core/css/CSSRuleList.h" |
| 40 #include "core/css/CSSStyleRule.h" | 39 #include "core/css/CSSStyleRule.h" |
| 41 #include "core/css/CSSStyleSheet.h" | 40 #include "core/css/CSSStyleSheet.h" |
| 42 #include "core/css/MediaList.h" | 41 #include "core/css/MediaList.h" |
| 43 #include "core/css/StylePropertySet.h" | 42 #include "core/css/StylePropertySet.h" |
| 44 #include "core/css/StyleRule.h" | 43 #include "core/css/StyleRule.h" |
| 45 #include "core/css/StyleSheet.h" | 44 #include "core/css/StyleSheet.h" |
| 46 #include "core/css/StyleSheetContents.h" | 45 #include "core/css/StyleSheetContents.h" |
| 47 #include "core/css/StyleSheetList.h" | 46 #include "core/css/StyleSheetList.h" |
| 48 #include "core/css/resolver/StyleResolver.h" | 47 #include "core/css/resolver/StyleResolver.h" |
| 49 #include "core/dom/Node.h" | 48 #include "core/dom/Node.h" |
| 50 #include "core/dom/NodeList.h" | 49 #include "core/dom/NodeList.h" |
| 51 #include "core/fetch/CSSStyleSheetResource.h" | |
| 52 #include "core/fetch/ResourceClient.h" | |
| 53 #include "core/fetch/ResourceFetcher.h" | |
| 54 #include "core/fetch/StyleSheetResourceClient.h" | |
| 55 #include "core/frame/LocalFrame.h" | 50 #include "core/frame/LocalFrame.h" |
| 56 #include "core/html/HTMLHeadElement.h" | 51 #include "core/html/HTMLHeadElement.h" |
| 57 #include "core/inspector/InspectorHistory.h" | 52 #include "core/inspector/InspectorHistory.h" |
| 58 #include "core/inspector/InspectorPageAgent.h" | 53 #include "core/inspector/InspectorPageAgent.h" |
| 59 #include "core/inspector/InspectorResourceAgent.h" | |
| 60 #include "core/inspector/InspectorState.h" | 54 #include "core/inspector/InspectorState.h" |
| 61 #include "core/inspector/InstrumentingAgents.h" | 55 #include "core/inspector/InstrumentingAgents.h" |
| 62 #include "core/loader/DocumentLoader.h" | 56 #include "core/loader/DocumentLoader.h" |
| 63 #include "core/page/Page.h" | 57 #include "core/page/Page.h" |
| 64 #include "core/rendering/InlineTextBox.h" | 58 #include "core/rendering/InlineTextBox.h" |
| 65 #include "core/rendering/RenderObject.h" | 59 #include "core/rendering/RenderObject.h" |
| 66 #include "core/rendering/RenderText.h" | 60 #include "core/rendering/RenderText.h" |
| 67 #include "core/rendering/RenderTextFragment.h" | 61 #include "core/rendering/RenderTextFragment.h" |
| 68 #include "platform/fonts/Font.h" | 62 #include "platform/fonts/Font.h" |
| 69 #include "platform/fonts/GlyphBuffer.h" | 63 #include "platform/fonts/GlyphBuffer.h" |
| 70 #include "platform/fonts/WidthIterator.h" | 64 #include "platform/fonts/WidthIterator.h" |
| 71 #include "platform/text/TextRun.h" | 65 #include "platform/text/TextRun.h" |
| 72 #include "wtf/CurrentTime.h" | 66 #include "wtf/CurrentTime.h" |
| 73 #include "wtf/text/CString.h" | 67 #include "wtf/text/CString.h" |
| 74 #include "wtf/text/StringConcatenate.h" | 68 #include "wtf/text/StringConcatenate.h" |
| 75 | 69 |
| 76 namespace CSSAgentState { | 70 namespace CSSAgentState { |
| 77 static const char cssAgentEnabled[] = "cssAgentEnabled"; | 71 static const char cssAgentEnabled[] = "cssAgentEnabled"; |
| 78 } | 72 } |
| 79 | 73 |
| 80 typedef WebCore::InspectorBackendDispatcher::CSSCommandHandler::EnableCallback E
nableCallback; | |
| 81 | |
| 82 namespace WebCore { | 74 namespace WebCore { |
| 83 | 75 |
| 84 enum ForcePseudoClassFlags { | 76 enum ForcePseudoClassFlags { |
| 85 PseudoNone = 0, | 77 PseudoNone = 0, |
| 86 PseudoHover = 1 << 0, | 78 PseudoHover = 1 << 0, |
| 87 PseudoFocus = 1 << 1, | 79 PseudoFocus = 1 << 1, |
| 88 PseudoActive = 1 << 2, | 80 PseudoActive = 1 << 2, |
| 89 PseudoVisited = 1 << 3 | 81 PseudoVisited = 1 << 3 |
| 90 }; | 82 }; |
| 91 | 83 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 120 | 112 |
| 121 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { | 113 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { |
| 122 WTF_MAKE_NONCOPYABLE(StyleSheetAction); | 114 WTF_MAKE_NONCOPYABLE(StyleSheetAction); |
| 123 public: | 115 public: |
| 124 StyleSheetAction(const String& name) | 116 StyleSheetAction(const String& name) |
| 125 : InspectorHistory::Action(name) | 117 : InspectorHistory::Action(name) |
| 126 { | 118 { |
| 127 } | 119 } |
| 128 }; | 120 }; |
| 129 | 121 |
| 130 class InspectorCSSAgent::EnableResourceClient FINAL : public StyleSheetResourceC
lient { | |
| 131 public: | |
| 132 EnableResourceClient(InspectorCSSAgent*, const Vector<InspectorStyleSheet*>&
, PassRefPtr<EnableCallback>); | |
| 133 | |
| 134 virtual void setCSSStyleSheet(const String&, const KURL&, const String&, con
st CSSStyleSheetResource*) OVERRIDE; | |
| 135 | |
| 136 private: | |
| 137 RefPtr<EnableCallback> m_callback; | |
| 138 InspectorCSSAgent* m_cssAgent; | |
| 139 int m_pendingResources; | |
| 140 Vector<InspectorStyleSheet*> m_styleSheets; | |
| 141 }; | |
| 142 | |
| 143 InspectorCSSAgent::EnableResourceClient::EnableResourceClient(InspectorCSSAgent*
cssAgent, const Vector<InspectorStyleSheet*>& styleSheets, PassRefPtr<EnableCal
lback> callback) | |
| 144 : m_callback(callback) | |
| 145 , m_cssAgent(cssAgent) | |
| 146 , m_pendingResources(styleSheets.size()) | |
| 147 , m_styleSheets(styleSheets) | |
| 148 { | |
| 149 for (size_t i = 0; i < styleSheets.size(); ++i) { | |
| 150 InspectorStyleSheet* styleSheet = styleSheets.at(i); | |
| 151 Document* document = styleSheet->ownerDocument(); | |
| 152 FetchRequest request(ResourceRequest(styleSheet->finalURL()), FetchIniti
atorTypeNames::internal); | |
| 153 ResourcePtr<Resource> resource = document->fetcher()->fetchCSSStyleSheet
(request); | |
| 154 resource->addClient(this); | |
| 155 } | |
| 156 } | |
| 157 | |
| 158 void InspectorCSSAgent::EnableResourceClient::setCSSStyleSheet(const String&, co
nst KURL& url, const String&, const CSSStyleSheetResource* resource) | |
| 159 { | |
| 160 const_cast<CSSStyleSheetResource*>(resource)->removeClient(this); | |
| 161 --m_pendingResources; | |
| 162 if (m_pendingResources) | |
| 163 return; | |
| 164 | |
| 165 // enable always succeeds. | |
| 166 if (m_callback->isActive()) | |
| 167 m_cssAgent->wasEnabled(m_callback.release()); | |
| 168 delete this; | |
| 169 } | |
| 170 | |
| 171 class InspectorCSSAgent::SetStyleSheetTextAction FINAL : public InspectorCSSAgen
t::StyleSheetAction { | 122 class InspectorCSSAgent::SetStyleSheetTextAction FINAL : public InspectorCSSAgen
t::StyleSheetAction { |
| 172 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); | 123 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); |
| 173 public: | 124 public: |
| 174 SetStyleSheetTextAction(InspectorStyleSheetBase* styleSheet, const String& t
ext) | 125 SetStyleSheetTextAction(InspectorStyleSheetBase* styleSheet, const String& t
ext) |
| 175 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText") | 126 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText") |
| 176 , m_styleSheet(styleSheet) | 127 , m_styleSheet(styleSheet) |
| 177 , m_text(text) | 128 , m_text(text) |
| 178 { | 129 { |
| 179 } | 130 } |
| 180 | 131 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 }; | 299 }; |
| 349 | 300 |
| 350 // static | 301 // static |
| 351 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) | 302 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) |
| 352 { | 303 { |
| 353 if (!rule || rule->type() != CSSRule::STYLE_RULE) | 304 if (!rule || rule->type() != CSSRule::STYLE_RULE) |
| 354 return 0; | 305 return 0; |
| 355 return toCSSStyleRule(rule); | 306 return toCSSStyleRule(rule); |
| 356 } | 307 } |
| 357 | 308 |
| 358 InspectorCSSAgent::InspectorCSSAgent(InspectorDOMAgent* domAgent, InspectorPageA
gent* pageAgent, InspectorResourceAgent* resourceAgent) | 309 InspectorCSSAgent::InspectorCSSAgent(InspectorDOMAgent* domAgent, InspectorPageA
gent* pageAgent) |
| 359 : InspectorBaseAgent<InspectorCSSAgent>("CSS") | 310 : InspectorBaseAgent<InspectorCSSAgent>("CSS") |
| 360 , m_frontend(0) | 311 , m_frontend(0) |
| 361 , m_domAgent(domAgent) | 312 , m_domAgent(domAgent) |
| 362 , m_pageAgent(pageAgent) | 313 , m_pageAgent(pageAgent) |
| 363 , m_resourceAgent(resourceAgent) | |
| 364 , m_lastStyleSheetId(1) | 314 , m_lastStyleSheetId(1) |
| 365 , m_styleSheetsPendingMutation(0) | 315 , m_styleSheetsPendingMutation(0) |
| 366 , m_styleDeclarationPendingMutation(false) | 316 , m_styleDeclarationPendingMutation(false) |
| 367 , m_creatingViaInspectorStyleSheet(false) | 317 , m_creatingViaInspectorStyleSheet(false) |
| 368 , m_isSettingStyleSheetText(false) | 318 , m_isSettingStyleSheetText(false) |
| 369 { | 319 { |
| 370 m_domAgent->setDOMListener(this); | 320 m_domAgent->setDOMListener(this); |
| 371 } | 321 } |
| 372 | 322 |
| 373 InspectorCSSAgent::~InspectorCSSAgent() | 323 InspectorCSSAgent::~InspectorCSSAgent() |
| (...skipping 19 matching lines...) Expand all Loading... |
| 393 | 343 |
| 394 void InspectorCSSAgent::discardAgent() | 344 void InspectorCSSAgent::discardAgent() |
| 395 { | 345 { |
| 396 m_domAgent->setDOMListener(0); | 346 m_domAgent->setDOMListener(0); |
| 397 m_domAgent = 0; | 347 m_domAgent = 0; |
| 398 } | 348 } |
| 399 | 349 |
| 400 void InspectorCSSAgent::restore() | 350 void InspectorCSSAgent::restore() |
| 401 { | 351 { |
| 402 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) | 352 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) |
| 403 wasEnabled(nullptr); | 353 wasEnabled(); |
| 404 } | 354 } |
| 405 | 355 |
| 406 void InspectorCSSAgent::flushPendingFrontendMessages() | 356 void InspectorCSSAgent::flushPendingFrontendMessages() |
| 407 { | 357 { |
| 408 if (!m_invalidatedDocuments.size()) | 358 if (!m_invalidatedDocuments.size()) |
| 409 return; | 359 return; |
| 410 HashSet<Document*> invalidatedDocuments; | 360 HashSet<Document*> invalidatedDocuments; |
| 411 m_invalidatedDocuments.swap(&invalidatedDocuments); | 361 m_invalidatedDocuments.swap(&invalidatedDocuments); |
| 412 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i
nvalidatedDocuments.end(); ++it) | 362 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i
nvalidatedDocuments.end(); ++it) |
| 413 updateActiveStyleSheets(*it, ExistingFrontendRefresh); | 363 updateActiveStyleSheets(*it, ExistingFrontendRefresh); |
| 414 } | 364 } |
| 415 | 365 |
| 416 void InspectorCSSAgent::reset() | 366 void InspectorCSSAgent::reset() |
| 417 { | 367 { |
| 418 m_idToInspectorStyleSheet.clear(); | 368 m_idToInspectorStyleSheet.clear(); |
| 419 m_idToInspectorStyleSheetForInlineStyle.clear(); | 369 m_idToInspectorStyleSheetForInlineStyle.clear(); |
| 420 m_cssStyleSheetToInspectorStyleSheet.clear(); | 370 m_cssStyleSheetToInspectorStyleSheet.clear(); |
| 421 m_documentToCSSStyleSheets.clear(); | 371 m_documentToCSSStyleSheets.clear(); |
| 422 m_invalidatedDocuments.clear(); | 372 m_invalidatedDocuments.clear(); |
| 423 m_nodeToInspectorStyleSheet.clear(); | 373 m_nodeToInspectorStyleSheet.clear(); |
| 424 m_documentToViaInspectorStyleSheet.clear(); | 374 m_documentToViaInspectorStyleSheet.clear(); |
| 425 resetNonPersistentData(); | 375 resetNonPersistentData(); |
| 426 } | 376 } |
| 427 | 377 |
| 428 void InspectorCSSAgent::resetNonPersistentData() | 378 void InspectorCSSAgent::resetNonPersistentData() |
| 429 { | 379 { |
| 430 resetPseudoStates(); | 380 resetPseudoStates(); |
| 431 } | 381 } |
| 432 | 382 |
| 433 void InspectorCSSAgent::enable(ErrorString*, PassRefPtr<EnableCallback> prpCallb
ack) | 383 void InspectorCSSAgent::enable(ErrorString*) |
| 434 { | 384 { |
| 435 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); | 385 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); |
| 436 | |
| 437 Vector<InspectorStyleSheet*> styleSheets; | 386 Vector<InspectorStyleSheet*> styleSheets; |
| 438 collectAllStyleSheets(styleSheets); | 387 bindAllStyleSheets(); |
| 439 | 388 wasEnabled(); |
| 440 // Re-issue stylesheet requets for resources that are no longer in memory ca
che. | |
| 441 Vector<InspectorStyleSheet*> styleSheetsToFetch; | |
| 442 HashSet<String> urlsToFetch; | |
| 443 for (size_t i = 0; i < styleSheets.size(); ++i) { | |
| 444 InspectorStyleSheet* styleSheet = styleSheets.at(i); | |
| 445 String url = styleSheet->finalURL(); | |
| 446 if (urlsToFetch.contains(url)) | |
| 447 continue; | |
| 448 CSSStyleSheet* pageStyleSheet = styleSheet->pageStyleSheet(); | |
| 449 if (pageStyleSheet->isInline() || !pageStyleSheet->contents()->loadCompl
eted()) | |
| 450 continue; | |
| 451 Document* document = styleSheet->ownerDocument(); | |
| 452 if (!document) | |
| 453 continue; | |
| 454 Resource* cachedResource = document->fetcher()->cachedResource(document-
>completeURL(url)); | |
| 455 if (cachedResource) | |
| 456 continue; | |
| 457 urlsToFetch.add(styleSheet->finalURL()); | |
| 458 styleSheetsToFetch.append(styleSheet); | |
| 459 } | |
| 460 | |
| 461 if (styleSheetsToFetch.isEmpty()) { | |
| 462 wasEnabled(prpCallback); | |
| 463 return; | |
| 464 } | |
| 465 new EnableResourceClient(this, styleSheetsToFetch, prpCallback); | |
| 466 } | 389 } |
| 467 | 390 |
| 468 void InspectorCSSAgent::wasEnabled(PassRefPtr<EnableCallback> callback) | 391 void InspectorCSSAgent::wasEnabled() |
| 469 { | 392 { |
| 470 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { | 393 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { |
| 471 // We were disabled while fetching resources. | 394 // We were disabled while fetching resources. |
| 472 return; | 395 return; |
| 473 } | 396 } |
| 474 | 397 |
| 475 m_instrumentingAgents->setInspectorCSSAgent(this); | 398 m_instrumentingAgents->setInspectorCSSAgent(this); |
| 476 Vector<Document*> documents = m_domAgent->documents(); | 399 Vector<Document*> documents = m_domAgent->documents(); |
| 477 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) | 400 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) |
| 478 updateActiveStyleSheets(*it, InitialFrontendLoad); | 401 updateActiveStyleSheets(*it, InitialFrontendLoad); |
| 479 | |
| 480 if (callback) | |
| 481 callback->sendSuccess(); | |
| 482 } | 402 } |
| 483 | 403 |
| 484 void InspectorCSSAgent::disable(ErrorString*) | 404 void InspectorCSSAgent::disable(ErrorString*) |
| 485 { | 405 { |
| 486 reset(); | 406 reset(); |
| 487 m_instrumentingAgents->setInspectorCSSAgent(0); | 407 m_instrumentingAgents->setInspectorCSSAgent(0); |
| 488 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); | 408 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); |
| 489 } | 409 } |
| 490 | 410 |
| 491 void InspectorCSSAgent::didCommitLoadForMainFrame() | 411 void InspectorCSSAgent::didCommitLoadForMainFrame() |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (styleSheetEditInProgress()) | 458 if (styleSheetEditInProgress()) |
| 539 return; | 459 return; |
| 540 m_invalidatedDocuments.add(document); | 460 m_invalidatedDocuments.add(document); |
| 541 if (m_creatingViaInspectorStyleSheet) | 461 if (m_creatingViaInspectorStyleSheet) |
| 542 flushPendingFrontendMessages(); | 462 flushPendingFrontendMessages(); |
| 543 } | 463 } |
| 544 | 464 |
| 545 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU
pdateType styleSheetsUpdateType) | 465 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU
pdateType styleSheetsUpdateType) |
| 546 { | 466 { |
| 547 Vector<CSSStyleSheet*> newSheetsVector; | 467 Vector<CSSStyleSheet*> newSheetsVector; |
| 548 collectAllDocumentStyleSheets(document, newSheetsVector); | 468 InspectorCSSAgent::collectAllDocumentStyleSheets(document, newSheetsVector); |
| 549 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); | 469 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); |
| 550 } | 470 } |
| 551 | 471 |
| 552 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS
SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) | 472 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS
SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) |
| 553 { | 473 { |
| 554 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; | 474 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; |
| 555 | 475 |
| 556 HashSet<CSSStyleSheet*>* documentCSSStyleSheets = m_documentToCSSStyleSheets
.get(document); | 476 HashSet<CSSStyleSheet*>* documentCSSStyleSheets = m_documentToCSSStyleSheets
.get(document); |
| 557 if (!documentCSSStyleSheets) { | 477 if (!documentCSSStyleSheets) { |
| 558 documentCSSStyleSheets = new HashSet<CSSStyleSheet*>(); | 478 documentCSSStyleSheets = new HashSet<CSSStyleSheet*>(); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 *errorString = "No node with given id found"; | 1021 *errorString = "No node with given id found"; |
| 1102 return 0; | 1022 return 0; |
| 1103 } | 1023 } |
| 1104 if (!node->isElementNode()) { | 1024 if (!node->isElementNode()) { |
| 1105 *errorString = "Not an element node"; | 1025 *errorString = "Not an element node"; |
| 1106 return 0; | 1026 return 0; |
| 1107 } | 1027 } |
| 1108 return toElement(node); | 1028 return toElement(node); |
| 1109 } | 1029 } |
| 1110 | 1030 |
| 1111 void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu
lt) | 1031 void InspectorCSSAgent::bindAllStyleSheets() |
| 1112 { | 1032 { |
| 1113 Vector<CSSStyleSheet*> cssStyleSheets; | 1033 Vector<CSSStyleSheet*> cssStyleSheets; |
| 1114 Vector<Document*> documents = m_domAgent->documents(); | 1034 Vector<Document*> documents = m_domAgent->documents(); |
| 1115 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) | 1035 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) |
| 1116 collectAllDocumentStyleSheets(*it, cssStyleSheets); | 1036 InspectorCSSAgent::collectAllDocumentStyleSheets(*it, cssStyleSheets); |
| 1117 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css
StyleSheets.end(); ++it) | 1037 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css
StyleSheets.end(); ++it) |
| 1118 result.append(bindStyleSheet(*it)); | 1038 bindStyleSheet(*it); |
| 1119 } | 1039 } |
| 1120 | 1040 |
| 1041 // static |
| 1121 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector
<CSSStyleSheet*>& result) | 1042 void InspectorCSSAgent::collectAllDocumentStyleSheets(Document* document, Vector
<CSSStyleSheet*>& result) |
| 1122 { | 1043 { |
| 1123 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheets =
document->styleEngine()->activeStyleSheetsForInspector(); | 1044 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheets =
document->styleEngine()->activeStyleSheetsForInspector(); |
| 1124 for (WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >::const_iterator it =
activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) { | 1045 for (WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >::const_iterator it =
activeStyleSheets.begin(); it != activeStyleSheets.end(); ++it) { |
| 1125 StyleSheet* styleSheet = it->get(); | 1046 StyleSheet* styleSheet = it->get(); |
| 1126 if (styleSheet->isCSSStyleSheet()) | 1047 if (styleSheet->isCSSStyleSheet()) |
| 1127 collectStyleSheets(toCSSStyleSheet(styleSheet), result); | 1048 InspectorCSSAgent::collectStyleSheets(toCSSStyleSheet(styleSheet), r
esult); |
| 1128 } | 1049 } |
| 1129 } | 1050 } |
| 1130 | 1051 |
| 1052 // static |
| 1131 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<CSS
StyleSheet*>& result) | 1053 void InspectorCSSAgent::collectStyleSheets(CSSStyleSheet* styleSheet, Vector<CSS
StyleSheet*>& result) |
| 1132 { | 1054 { |
| 1133 result.append(styleSheet); | 1055 result.append(styleSheet); |
| 1134 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { | 1056 for (unsigned i = 0, size = styleSheet->length(); i < size; ++i) { |
| 1135 CSSRule* rule = styleSheet->item(i); | 1057 CSSRule* rule = styleSheet->item(i); |
| 1136 if (rule->type() == CSSRule::IMPORT_RULE) { | 1058 if (rule->type() == CSSRule::IMPORT_RULE) { |
| 1137 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); | 1059 CSSStyleSheet* importedStyleSheet = toCSSImportRule(rule)->styleShee
t(); |
| 1138 if (importedStyleSheet) | 1060 if (importedStyleSheet) |
| 1139 collectStyleSheets(importedStyleSheet, result); | 1061 InspectorCSSAgent::collectStyleSheets(importedStyleSheet, result
); |
| 1140 } | 1062 } |
| 1141 } | 1063 } |
| 1142 } | 1064 } |
| 1143 | 1065 |
| 1144 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) | 1066 InspectorStyleSheet* InspectorCSSAgent::bindStyleSheet(CSSStyleSheet* styleSheet
) |
| 1145 { | 1067 { |
| 1146 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector
StyleSheet.get(styleSheet); | 1068 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspector
StyleSheet.get(styleSheet); |
| 1147 if (!inspectorStyleSheet) { | 1069 if (!inspectorStyleSheet) { |
| 1148 String id = String::number(m_lastStyleSheetId++); | 1070 String id = String::number(m_lastStyleSheetId++); |
| 1149 Document* document = styleSheet->ownerDocument(); | 1071 Document* document = styleSheet->ownerDocument(); |
| 1150 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, m_resourc
eAgent, id, styleSheet, detectOrigin(styleSheet, document), InspectorDOMAgent::d
ocumentURLString(document), this); | 1072 inspectorStyleSheet = InspectorStyleSheet::create(m_pageAgent, id, style
Sheet, detectOrigin(styleSheet, document), InspectorDOMAgent::documentURLString(
document), this); |
| 1151 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); | 1073 m_idToInspectorStyleSheet.set(id, inspectorStyleSheet); |
| 1152 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); | 1074 m_cssStyleSheetToInspectorStyleSheet.set(styleSheet, inspectorStyleSheet
); |
| 1153 if (m_creatingViaInspectorStyleSheet) | 1075 if (m_creatingViaInspectorStyleSheet) |
| 1154 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); | 1076 m_documentToViaInspectorStyleSheet.add(document, inspectorStyleSheet
); |
| 1155 } | 1077 } |
| 1156 return inspectorStyleSheet.get(); | 1078 return inspectorStyleSheet.get(); |
| 1157 } | 1079 } |
| 1158 | 1080 |
| 1159 String InspectorCSSAgent::unbindStyleSheet(InspectorStyleSheet* inspectorStyleSh
eet) | 1081 String InspectorCSSAgent::unbindStyleSheet(InspectorStyleSheet* inspectorStyleSh
eet) |
| 1160 { | 1082 { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1387 documentsToChange.add(element->ownerDocument()); | 1309 documentsToChange.add(element->ownerDocument()); |
| 1388 } | 1310 } |
| 1389 | 1311 |
| 1390 m_nodeIdToForcedPseudoState.clear(); | 1312 m_nodeIdToForcedPseudoState.clear(); |
| 1391 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1313 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
| 1392 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1314 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1393 } | 1315 } |
| 1394 | 1316 |
| 1395 } // namespace WebCore | 1317 } // namespace WebCore |
| 1396 | 1318 |
| OLD | NEW |