| 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 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 private: | 211 private: |
| 212 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; | 212 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
| 213 String m_text; | 213 String m_text; |
| 214 String m_oldText; | 214 String m_oldText; |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 class InspectorCSSAgent::SetPropertyTextAction final : public InspectorCSSAgent:
:StyleSheetAction { | 217 class InspectorCSSAgent::SetPropertyTextAction final : public InspectorCSSAgent:
:StyleSheetAction { |
| 218 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); | 218 WTF_MAKE_NONCOPYABLE(SetPropertyTextAction); |
| 219 public: | 219 public: |
| 220 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, const InspectorCS
SId& cssId, unsigned propertyIndex, const String& text, bool overwrite) | 220 SetPropertyTextAction(InspectorStyleSheetBase* styleSheet, unsigned ruleInde
x, unsigned propertyIndex, const String& text, bool overwrite) |
| 221 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") | 221 : InspectorCSSAgent::StyleSheetAction("SetPropertyText") |
| 222 , m_styleSheet(styleSheet) | 222 , m_styleSheet(styleSheet) |
| 223 , m_cssId(cssId) | 223 , m_ruleIndex(ruleIndex) |
| 224 , m_propertyIndex(propertyIndex) | 224 , m_propertyIndex(propertyIndex) |
| 225 , m_text(text) | 225 , m_text(text) |
| 226 , m_overwrite(overwrite) | 226 , m_overwrite(overwrite) |
| 227 { | 227 { |
| 228 } | 228 } |
| 229 | 229 |
| 230 virtual String toString() override | 230 virtual String toString() override |
| 231 { | 231 { |
| 232 return mergeId() + ": " + m_oldStyleText + " -> " + m_text; | 232 return mergeId() + ": " + m_oldStyleText + " -> " + m_text; |
| 233 } | 233 } |
| 234 | 234 |
| 235 virtual bool perform(ExceptionState& exceptionState) override | 235 virtual bool perform(ExceptionState& exceptionState) override |
| 236 { | 236 { |
| 237 return redo(exceptionState); | 237 return redo(exceptionState); |
| 238 } | 238 } |
| 239 | 239 |
| 240 virtual bool undo(ExceptionState& exceptionState) override | 240 virtual bool undo(ExceptionState& exceptionState) override |
| 241 { | 241 { |
| 242 String placeholder; | 242 String placeholder; |
| 243 return m_styleSheet->setStyleText(m_cssId, m_oldStyleText); | 243 return m_styleSheet->setStyleText(m_ruleIndex, m_oldStyleText); |
| 244 } | 244 } |
| 245 | 245 |
| 246 virtual bool redo(ExceptionState& exceptionState) override | 246 virtual bool redo(ExceptionState& exceptionState) override |
| 247 { | 247 { |
| 248 if (!m_styleSheet->getStyleText(m_cssId, &m_oldStyleText)) | 248 if (!m_styleSheet->getStyleText(m_ruleIndex, &m_oldStyleText)) |
| 249 return false; | 249 return false; |
| 250 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_
text, m_overwrite, exceptionState); | 250 bool result = m_styleSheet->setPropertyText(m_ruleIndex, m_propertyIndex
, m_text, m_overwrite, exceptionState); |
| 251 m_styleSheet->getStyleText(m_cssId, &m_newStyleText); | 251 m_styleSheet->getStyleText(m_ruleIndex, &m_newStyleText); |
| 252 return result; | 252 return result; |
| 253 } | 253 } |
| 254 | 254 |
| 255 virtual String mergeId() override | 255 virtual String mergeId() override |
| 256 { | 256 { |
| 257 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf
8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); | 257 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf
8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); |
| 258 } | 258 } |
| 259 | 259 |
| 260 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override | 260 virtual void merge(PassRefPtrWillBeRawPtr<Action> action) override |
| 261 { | 261 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 272 } | 272 } |
| 273 | 273 |
| 274 DEFINE_INLINE_VIRTUAL_TRACE() | 274 DEFINE_INLINE_VIRTUAL_TRACE() |
| 275 { | 275 { |
| 276 visitor->trace(m_styleSheet); | 276 visitor->trace(m_styleSheet); |
| 277 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 277 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 278 } | 278 } |
| 279 | 279 |
| 280 private: | 280 private: |
| 281 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; | 281 RefPtrWillBeMember<InspectorStyleSheetBase> m_styleSheet; |
| 282 InspectorCSSId m_cssId; | 282 unsigned m_ruleIndex; |
| 283 unsigned m_propertyIndex; | 283 unsigned m_propertyIndex; |
| 284 String m_text; | 284 String m_text; |
| 285 String m_oldStyleText; | 285 String m_oldStyleText; |
| 286 String m_newStyleText; | 286 String m_newStyleText; |
| 287 bool m_overwrite; | 287 bool m_overwrite; |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 class InspectorCSSAgent::SetRuleSelectorAction final : public InspectorCSSAgent:
:StyleSheetAction { | 290 class InspectorCSSAgent::SetRuleSelectorAction final : public InspectorCSSAgent:
:StyleSheetAction { |
| 291 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); | 291 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); |
| 292 public: | 292 public: |
| 293 SetRuleSelectorAction(InspectorStyleSheet* styleSheet, const InspectorCSSId&
cssId, const String& selector) | 293 SetRuleSelectorAction(InspectorStyleSheet* styleSheet, unsigned ruleIndex, c
onst String& selector) |
| 294 : InspectorCSSAgent::StyleSheetAction("SetRuleSelector") | 294 : InspectorCSSAgent::StyleSheetAction("SetRuleSelector") |
| 295 , m_styleSheet(styleSheet) | 295 , m_styleSheet(styleSheet) |
| 296 , m_cssId(cssId) | 296 , m_ruleIndex(ruleIndex) |
| 297 , m_selector(selector) | 297 , m_selector(selector) |
| 298 { | 298 { |
| 299 } | 299 } |
| 300 | 300 |
| 301 virtual bool perform(ExceptionState& exceptionState) override | 301 virtual bool perform(ExceptionState& exceptionState) override |
| 302 { | 302 { |
| 303 m_oldSelector = m_styleSheet->ruleSelector(m_cssId, exceptionState); | 303 m_oldSelector = m_styleSheet->ruleSelector(m_ruleIndex, exceptionState); |
| 304 if (exceptionState.hadException()) | 304 if (exceptionState.hadException()) |
| 305 return false; | 305 return false; |
| 306 return redo(exceptionState); | 306 return redo(exceptionState); |
| 307 } | 307 } |
| 308 | 308 |
| 309 virtual bool undo(ExceptionState& exceptionState) override | 309 virtual bool undo(ExceptionState& exceptionState) override |
| 310 { | 310 { |
| 311 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt
ate); | 311 return m_styleSheet->setRuleSelector(m_ruleIndex, m_oldSelector, excepti
onState); |
| 312 } | 312 } |
| 313 | 313 |
| 314 virtual bool redo(ExceptionState& exceptionState) override | 314 virtual bool redo(ExceptionState& exceptionState) override |
| 315 { | 315 { |
| 316 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState
); | 316 return m_styleSheet->setRuleSelector(m_ruleIndex, m_selector, exceptionS
tate); |
| 317 } | 317 } |
| 318 | 318 |
| 319 DEFINE_INLINE_VIRTUAL_TRACE() | 319 DEFINE_INLINE_VIRTUAL_TRACE() |
| 320 { | 320 { |
| 321 visitor->trace(m_styleSheet); | 321 visitor->trace(m_styleSheet); |
| 322 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 322 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 323 } | 323 } |
| 324 | 324 |
| 325 private: | 325 private: |
| 326 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; | 326 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
| 327 InspectorCSSId m_cssId; | 327 unsigned m_ruleIndex; |
| 328 String m_selector; | 328 String m_selector; |
| 329 String m_oldSelector; | 329 String m_oldSelector; |
| 330 }; | 330 }; |
| 331 | 331 |
| 332 class InspectorCSSAgent::SetMediaTextAction final : public InspectorCSSAgent::St
yleSheetAction { | 332 class InspectorCSSAgent::SetMediaTextAction final : public InspectorCSSAgent::St
yleSheetAction { |
| 333 WTF_MAKE_NONCOPYABLE(SetMediaTextAction); | 333 WTF_MAKE_NONCOPYABLE(SetMediaTextAction); |
| 334 public: | 334 public: |
| 335 SetMediaTextAction(InspectorStyleSheet* styleSheet, const InspectorCSSId& cs
sId, const String& text) | 335 SetMediaTextAction(InspectorStyleSheet* styleSheet, unsigned ruleIndex, cons
t String& text) |
| 336 : InspectorCSSAgent::StyleSheetAction("SetMediaText") | 336 : InspectorCSSAgent::StyleSheetAction("SetMediaText") |
| 337 , m_styleSheet(styleSheet) | 337 , m_styleSheet(styleSheet) |
| 338 , m_cssId(cssId) | 338 , m_ruleIndex(ruleIndex) |
| 339 , m_text(text) | 339 , m_text(text) |
| 340 { | 340 { |
| 341 } | 341 } |
| 342 | 342 |
| 343 virtual bool perform(ExceptionState& exceptionState) override | 343 virtual bool perform(ExceptionState& exceptionState) override |
| 344 { | 344 { |
| 345 m_oldText = m_styleSheet->mediaRuleText(m_cssId, exceptionState); | 345 m_oldText = m_styleSheet->mediaRuleText(m_ruleIndex, exceptionState); |
| 346 if (exceptionState.hadException()) | 346 if (exceptionState.hadException()) |
| 347 return false; | 347 return false; |
| 348 return redo(exceptionState); | 348 return redo(exceptionState); |
| 349 } | 349 } |
| 350 | 350 |
| 351 virtual bool undo(ExceptionState& exceptionState) override | 351 virtual bool undo(ExceptionState& exceptionState) override |
| 352 { | 352 { |
| 353 return m_styleSheet->setMediaRuleText(m_cssId, m_oldText, exceptionState
); | 353 return m_styleSheet->setMediaRuleText(m_ruleIndex, m_oldText, exceptionS
tate); |
| 354 } | 354 } |
| 355 | 355 |
| 356 virtual bool redo(ExceptionState& exceptionState) override | 356 virtual bool redo(ExceptionState& exceptionState) override |
| 357 { | 357 { |
| 358 return m_styleSheet->setMediaRuleText(m_cssId, m_text, exceptionState); | 358 return m_styleSheet->setMediaRuleText(m_ruleIndex, m_text, exceptionStat
e); |
| 359 } | 359 } |
| 360 | 360 |
| 361 DEFINE_INLINE_VIRTUAL_TRACE() | 361 DEFINE_INLINE_VIRTUAL_TRACE() |
| 362 { | 362 { |
| 363 visitor->trace(m_styleSheet); | 363 visitor->trace(m_styleSheet); |
| 364 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 364 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 365 } | 365 } |
| 366 | 366 |
| 367 private: | 367 private: |
| 368 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; | 368 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
| 369 InspectorCSSId m_cssId; | 369 unsigned m_ruleIndex; |
| 370 String m_text; | 370 String m_text; |
| 371 String m_oldText; | 371 String m_oldText; |
| 372 }; | 372 }; |
| 373 | 373 |
| 374 class InspectorCSSAgent::AddRuleAction final : public InspectorCSSAgent::StyleSh
eetAction { | 374 class InspectorCSSAgent::AddRuleAction final : public InspectorCSSAgent::StyleSh
eetAction { |
| 375 WTF_MAKE_NONCOPYABLE(AddRuleAction); | 375 WTF_MAKE_NONCOPYABLE(AddRuleAction); |
| 376 public: | 376 public: |
| 377 AddRuleAction(InspectorStyleSheet* styleSheet, const String& ruleText, const
SourceRange& location) | 377 AddRuleAction(InspectorStyleSheet* styleSheet, const String& ruleText, const
SourceRange& location) |
| 378 : InspectorCSSAgent::StyleSheetAction("AddRule") | 378 : InspectorCSSAgent::StyleSheetAction("AddRule") |
| 379 , m_styleSheet(styleSheet) | 379 , m_styleSheet(styleSheet) |
| 380 , m_ruleText(ruleText) | 380 , m_ruleText(ruleText) |
| 381 , m_location(location) | 381 , m_location(location) |
| 382 { | 382 { |
| 383 } | 383 } |
| 384 | 384 |
| 385 virtual bool perform(ExceptionState& exceptionState) override | 385 virtual bool perform(ExceptionState& exceptionState) override |
| 386 { | 386 { |
| 387 return redo(exceptionState); | 387 return redo(exceptionState); |
| 388 } | 388 } |
| 389 | 389 |
| 390 virtual bool undo(ExceptionState& exceptionState) override | 390 virtual bool undo(ExceptionState& exceptionState) override |
| 391 { | 391 { |
| 392 return m_styleSheet->deleteRule(m_newId, m_oldText, exceptionState); | 392 return m_styleSheet->deleteRule(m_newOrdinal, m_oldText, exceptionState)
; |
| 393 } | 393 } |
| 394 | 394 |
| 395 virtual bool redo(ExceptionState& exceptionState) override | 395 virtual bool redo(ExceptionState& exceptionState) override |
| 396 { | 396 { |
| 397 if (!m_styleSheet->getText(&m_oldText)) | 397 if (!m_styleSheet->getText(&m_oldText)) |
| 398 return false; | 398 return false; |
| 399 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_ruleText, m_locatio
n, exceptionState); | 399 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_ruleText, m_locatio
n, exceptionState); |
| 400 if (exceptionState.hadException()) | 400 if (exceptionState.hadException()) |
| 401 return false; | 401 return false; |
| 402 m_newId = m_styleSheet->ruleId(cssStyleRule); | 402 m_newOrdinal = m_styleSheet->indexOf(cssStyleRule); |
| 403 return true; | 403 return true; |
| 404 } | 404 } |
| 405 | 405 |
| 406 InspectorCSSId newRuleId() { return m_newId; } | 406 unsigned newRuleOrdinal() { return m_newOrdinal; } |
| 407 | 407 |
| 408 DEFINE_INLINE_VIRTUAL_TRACE() | 408 DEFINE_INLINE_VIRTUAL_TRACE() |
| 409 { | 409 { |
| 410 visitor->trace(m_styleSheet); | 410 visitor->trace(m_styleSheet); |
| 411 InspectorCSSAgent::StyleSheetAction::trace(visitor); | 411 InspectorCSSAgent::StyleSheetAction::trace(visitor); |
| 412 } | 412 } |
| 413 | 413 |
| 414 private: | 414 private: |
| 415 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; | 415 RefPtrWillBeMember<InspectorStyleSheet> m_styleSheet; |
| 416 InspectorCSSId m_newId; | 416 unsigned m_newOrdinal; |
| 417 String m_ruleText; | 417 String m_ruleText; |
| 418 String m_oldText; | 418 String m_oldText; |
| 419 SourceRange m_location; | 419 SourceRange m_location; |
| 420 }; | 420 }; |
| 421 | 421 |
| 422 // static | 422 // static |
| 423 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) | 423 CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule) |
| 424 { | 424 { |
| 425 if (!rule || rule->type() != CSSRule::STYLE_RULE) | 425 if (!rule || rule->type() != CSSRule::STYLE_RULE) |
| 426 return nullptr; | 426 return nullptr; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri
es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); | 776 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri
es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); |
| 777 Element* parentElement = element->parentElement(); | 777 Element* parentElement = element->parentElement(); |
| 778 while (parentElement) { | 778 while (parentElement) { |
| 779 StyleResolver& parentStyleResolver = parentElement->ownerDocument()-
>ensureStyleResolver(); | 779 StyleResolver& parentStyleResolver = parentElement->ownerDocument()-
>ensureStyleResolver(); |
| 780 RefPtrWillBeRawPtr<CSSRuleList> parentMatchedRules = parentStyleReso
lver.cssRulesForElement(parentElement, StyleResolver::AllCSSRules); | 780 RefPtrWillBeRawPtr<CSSRuleList> parentMatchedRules = parentStyleReso
lver.cssRulesForElement(parentElement, StyleResolver::AllCSSRules); |
| 781 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C
SS::InheritedStyleEntry::create() | 781 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C
SS::InheritedStyleEntry::create() |
| 782 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu
les.get(), parentElement, NOPSEUDO)); | 782 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu
les.get(), parentElement, NOPSEUDO)); |
| 783 if (parentElement->style() && parentElement->style()->length()) { | 783 if (parentElement->style() && parentElement->style()->length()) { |
| 784 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle
Sheet(parentElement); | 784 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle
Sheet(parentElement); |
| 785 if (styleSheet) | 785 if (styleSheet) |
| 786 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS
heet->styleForId(InspectorCSSId(styleSheet->id(), 0)))); | 786 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS
heet->styleAt(0))); |
| 787 } | 787 } |
| 788 | 788 |
| 789 entries->addItem(entry.release()); | 789 entries->addItem(entry.release()); |
| 790 parentElement = parentElement->parentElement(); | 790 parentElement = parentElement->parentElement(); |
| 791 } | 791 } |
| 792 | 792 |
| 793 inheritedEntries = entries.release(); | 793 inheritedEntries = entries.release(); |
| 794 } | 794 } |
| 795 } | 795 } |
| 796 | 796 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 809 attributesStyle = attributes ? attributes.release() : nullptr; | 809 attributesStyle = attributes ? attributes.release() : nullptr; |
| 810 } | 810 } |
| 811 | 811 |
| 812 void InspectorCSSAgent::getComputedStyleForNode(ErrorString* errorString, int no
deId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >& s
tyle) | 812 void InspectorCSSAgent::getComputedStyleForNode(ErrorString* errorString, int no
deId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::CSSComputedStyleProperty> >& s
tyle) |
| 813 { | 813 { |
| 814 Node* node = m_domAgent->assertNode(errorString, nodeId); | 814 Node* node = m_domAgent->assertNode(errorString, nodeId); |
| 815 if (!node) | 815 if (!node) |
| 816 return; | 816 return; |
| 817 | 817 |
| 818 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSCompu
tedStyleDeclaration::create(node, true); | 818 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleInfo = CSSCompu
tedStyleDeclaration::create(node, true); |
| 819 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(I
nspectorCSSId(), computedStyleInfo, 0); | 819 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(0
, computedStyleInfo, 0); |
| 820 style = inspectorStyle->buildArrayForComputedStyle(); | 820 style = inspectorStyle->buildArrayForComputedStyle(); |
| 821 } | 821 } |
| 822 | 822 |
| 823 void InspectorCSSAgent::collectPlatformFontsForLayoutObject(LayoutText* layoutOb
ject, HashCountedSet<String>* fontStats) | 823 void InspectorCSSAgent::collectPlatformFontsForLayoutObject(LayoutText* layoutOb
ject, HashCountedSet<String>* fontStats) |
| 824 { | 824 { |
| 825 for (InlineTextBox* box = layoutObject->firstTextBox(); box; box = box->next
TextBox()) { | 825 for (InlineTextBox* box = layoutObject->firstTextBox(); box; box = box->next
TextBox()) { |
| 826 const ComputedStyle& style = layoutObject->styleRef(box->isFirstLineStyl
e()); | 826 const ComputedStyle& style = layoutObject->styleRef(box->isFirstLineStyl
e()); |
| 827 const Font& font = style.font(); | 827 const Font& font = style.font(); |
| 828 TextRun run = box->constructTextRunForInspector(style, font); | 828 TextRun run = box->constructTextRunForInspector(style, font); |
| 829 SimpleShaper shaper(&font, run); | 829 SimpleShaper shaper(&font, run); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 } | 954 } |
| 955 | 955 |
| 956 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const String&
styleSheetId, const RefPtr<JSONObject>& range, const String& text, RefPtr<TypeBu
ilder::CSS::CSSStyle>& result) | 956 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const String&
styleSheetId, const RefPtr<JSONObject>& range, const String& text, RefPtr<TypeBu
ilder::CSS::CSSStyle>& result) |
| 957 { | 957 { |
| 958 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, styleSheetId); | 958 InspectorStyleSheetBase* inspectorStyleSheet = assertStyleSheetForId(errorSt
ring, styleSheetId); |
| 959 if (!inspectorStyleSheet) | 959 if (!inspectorStyleSheet) |
| 960 return; | 960 return; |
| 961 SourceRange propertyRange; | 961 SourceRange propertyRange; |
| 962 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &proper
tyRange)) | 962 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &proper
tyRange)) |
| 963 return; | 963 return; |
| 964 InspectorCSSId compoundId; | 964 unsigned ruleIndex = 0; |
| 965 unsigned propertyIndex; | 965 unsigned propertyIndex = 0; |
| 966 bool overwrite; | 966 bool overwrite; |
| 967 if (!inspectorStyleSheet->findPropertyByRange(propertyRange, &compoundId, &p
ropertyIndex, &overwrite)) { | 967 if (!inspectorStyleSheet->findPropertyByRange(propertyRange, &ruleIndex, &pr
opertyIndex, &overwrite)) { |
| 968 *errorString = "Source range didn't match any existing property source r
ange nor any property insertion point"; | 968 *errorString = "Source range didn't match any existing property source r
ange nor any property insertion point"; |
| 969 return; | 969 return; |
| 970 } | 970 } |
| 971 | 971 |
| 972 TrackExceptionState exceptionState; | 972 TrackExceptionState exceptionState; |
| 973 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetProp
ertyTextAction(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite))
, exceptionState); | 973 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetProp
ertyTextAction(inspectorStyleSheet, ruleIndex, propertyIndex, text, overwrite)),
exceptionState); |
| 974 if (success) | 974 if (success) |
| 975 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleForId(compoundId)); | 975 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s
tyleAt(ruleIndex)); |
| 976 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 976 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
| 977 } | 977 } |
| 978 | 978 |
| 979 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String&
styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<Ty
peBuilder::CSS::CSSRule>& result) | 979 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const String&
styleSheetId, const RefPtr<JSONObject>& range, const String& selector, RefPtr<Ty
peBuilder::CSS::CSSRule>& result) |
| 980 { | 980 { |
| 981 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); | 981 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); |
| 982 if (!inspectorStyleSheet) { | 982 if (!inspectorStyleSheet) { |
| 983 *errorString = "Stylesheet not found"; | 983 *errorString = "Stylesheet not found"; |
| 984 return; | 984 return; |
| 985 } | 985 } |
| 986 SourceRange selectorRange; | 986 SourceRange selectorRange; |
| 987 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &select
orRange)) | 987 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &select
orRange)) |
| 988 return; | 988 return; |
| 989 InspectorCSSId compoundId; | 989 unsigned ruleIndex = 0; |
| 990 if (!inspectorStyleSheet->findRuleBySelectorRange(selectorRange, &compoundId
)) { | 990 if (!inspectorStyleSheet->findRuleBySelectorRange(selectorRange, &ruleIndex)
) { |
| 991 *errorString = "Source range didn't match any rule selector source range
"; | 991 *errorString = "Source range didn't match any rule selector source range
"; |
| 992 return; | 992 return; |
| 993 } | 993 } |
| 994 | 994 |
| 995 TrackExceptionState exceptionState; | 995 TrackExceptionState exceptionState; |
| 996 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetRule
SelectorAction(inspectorStyleSheet, compoundId, selector)), exceptionState); | 996 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetRule
SelectorAction(inspectorStyleSheet, ruleIndex, selector)), exceptionState); |
| 997 if (success) { | 997 if (success) { |
| 998 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); | 998 CSSStyleRule* rule = inspectorStyleSheet->ruleAt(ruleIndex); |
| 999 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); | 999 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha
in(rule)); |
| 1000 } | 1000 } |
| 1001 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 1001 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 void InspectorCSSAgent::setMediaText(ErrorString* errorString, const String& sty
leSheetId, const RefPtr<JSONObject>& range, const String& text, RefPtr<TypeBuild
er::CSS::CSSMedia>& result) | 1004 void InspectorCSSAgent::setMediaText(ErrorString* errorString, const String& sty
leSheetId, const RefPtr<JSONObject>& range, const String& text, RefPtr<TypeBuild
er::CSS::CSSMedia>& result) |
| 1005 { | 1005 { |
| 1006 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); | 1006 InspectorStyleSheet* inspectorStyleSheet = assertInspectorStyleSheetForId(er
rorString, styleSheetId); |
| 1007 if (!inspectorStyleSheet) { | 1007 if (!inspectorStyleSheet) { |
| 1008 *errorString = "Stylesheet not found"; | 1008 *errorString = "Stylesheet not found"; |
| 1009 return; | 1009 return; |
| 1010 } | 1010 } |
| 1011 SourceRange textRange; | 1011 SourceRange textRange; |
| 1012 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &textRa
nge)) | 1012 if (!jsonRangeToSourceRange(errorString, inspectorStyleSheet, range, &textRa
nge)) |
| 1013 return; | 1013 return; |
| 1014 InspectorCSSId compoundId; | 1014 unsigned ruleIndex = 0; |
| 1015 if (!inspectorStyleSheet->findMediaRuleByRange(textRange, &compoundId)) { | 1015 if (!inspectorStyleSheet->findMediaRuleByRange(textRange, &ruleIndex)) { |
| 1016 *errorString = "Source range didn't match any media rule source range"; | 1016 *errorString = "Source range didn't match any media rule source range"; |
| 1017 return; | 1017 return; |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 TrackExceptionState exceptionState; | 1020 TrackExceptionState exceptionState; |
| 1021 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetMedi
aTextAction(inspectorStyleSheet, compoundId, text)), exceptionState); | 1021 bool success = m_domAgent->history()->perform(adoptRefWillBeNoop(new SetMedi
aTextAction(inspectorStyleSheet, ruleIndex, text)), exceptionState); |
| 1022 if (success) { | 1022 if (success) { |
| 1023 CSSMediaRule* rule = inspectorStyleSheet->mediaRuleForId(compoundId); | 1023 CSSMediaRule* rule = inspectorStyleSheet->mediaRuleAt(ruleIndex); |
| 1024 String sourceURL = rule->parentStyleSheet()->contents()->baseURL(); | 1024 String sourceURL = rule->parentStyleSheet()->contents()->baseURL(); |
| 1025 if (sourceURL.isEmpty()) | 1025 if (sourceURL.isEmpty()) |
| 1026 sourceURL = InspectorDOMAgent::documentURLString(rule->parentStyleSh
eet()->ownerDocument()); | 1026 sourceURL = InspectorDOMAgent::documentURLString(rule->parentStyleSh
eet()->ownerDocument()); |
| 1027 result = buildMediaObject(rule->media(), MediaListSourceMediaRule, sourc
eURL, rule->parentStyleSheet()); | 1027 result = buildMediaObject(rule->media(), MediaListSourceMediaRule, sourc
eURL, rule->parentStyleSheet()); |
| 1028 } | 1028 } |
| 1029 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 1029 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) | 1032 void InspectorCSSAgent::createStyleSheet(ErrorString* errorString, const String&
frameId, TypeBuilder::CSS::StyleSheetId* outStyleSheetId) |
| 1033 { | 1033 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1064 return; | 1064 return; |
| 1065 | 1065 |
| 1066 TrackExceptionState exceptionState; | 1066 TrackExceptionState exceptionState; |
| 1067 RefPtrWillBeRawPtr<AddRuleAction> action = adoptRefWillBeNoop(new AddRuleAct
ion(inspectorStyleSheet, ruleText, ruleLocation)); | 1067 RefPtrWillBeRawPtr<AddRuleAction> action = adoptRefWillBeNoop(new AddRuleAct
ion(inspectorStyleSheet, ruleText, ruleLocation)); |
| 1068 bool success = m_domAgent->history()->perform(action, exceptionState); | 1068 bool success = m_domAgent->history()->perform(action, exceptionState); |
| 1069 if (!success) { | 1069 if (!success) { |
| 1070 *errorString = InspectorDOMAgent::toErrorString(exceptionState); | 1070 *errorString = InspectorDOMAgent::toErrorString(exceptionState); |
| 1071 return; | 1071 return; |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 InspectorCSSId ruleId = action->newRuleId(); | 1074 unsigned ruleOrdinal = action->newRuleOrdinal(); |
| 1075 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); | 1075 CSSStyleRule* rule = inspectorStyleSheet->ruleAt(ruleOrdinal); |
| 1076 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r
ule)); | 1076 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r
ule)); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, c
onst RefPtr<JSONArray>& forcedPseudoClasses) | 1079 void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, c
onst RefPtr<JSONArray>& forcedPseudoClasses) |
| 1080 { | 1080 { |
| 1081 Element* element = m_domAgent->assertElement(errorString, nodeId); | 1081 Element* element = m_domAgent->assertElement(errorString, nodeId); |
| 1082 if (!element) | 1082 if (!element) |
| 1083 return; | 1083 return; |
| 1084 | 1084 |
| 1085 unsigned forcedPseudoState = computePseudoClassMask(forcedPseudoClasses.get(
)); | 1085 unsigned forcedPseudoState = computePseudoClassMask(forcedPseudoClasses.get(
)); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 if (!element->isStyledElement()) | 1498 if (!element->isStyledElement()) |
| 1499 return nullptr; | 1499 return nullptr; |
| 1500 | 1500 |
| 1501 // FIXME: Ugliness below. | 1501 // FIXME: Ugliness below. |
| 1502 StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->pr
esentationAttributeStyle()); | 1502 StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->pr
esentationAttributeStyle()); |
| 1503 if (!attributeStyle) | 1503 if (!attributeStyle) |
| 1504 return nullptr; | 1504 return nullptr; |
| 1505 | 1505 |
| 1506 MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(a
ttributeStyle); | 1506 MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(a
ttributeStyle); |
| 1507 | 1507 |
| 1508 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(I
nspectorCSSId(), mutableAttributeStyle->ensureCSSStyleDeclaration(), 0); | 1508 RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(0
, mutableAttributeStyle->ensureCSSStyleDeclaration(), 0); |
| 1509 return inspectorStyle->buildObjectForStyle(); | 1509 return inspectorStyle->buildObjectForStyle(); |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 void InspectorCSSAgent::didRemoveDocument(Document* document) | 1512 void InspectorCSSAgent::didRemoveDocument(Document* document) |
| 1513 { | 1513 { |
| 1514 if (document) | 1514 if (document) |
| 1515 m_documentToViaInspectorStyleSheet.remove(document); | 1515 m_documentToViaInspectorStyleSheet.remove(document); |
| 1516 } | 1516 } |
| 1517 | 1517 |
| 1518 void InspectorCSSAgent::didRemoveDOMNode(Node* node) | 1518 void InspectorCSSAgent::didRemoveDOMNode(Node* node) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 visitor->trace(m_invalidatedDocuments); | 1589 visitor->trace(m_invalidatedDocuments); |
| 1590 visitor->trace(m_nodeToInspectorStyleSheet); | 1590 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1591 visitor->trace(m_documentToViaInspectorStyleSheet); | 1591 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1592 #endif | 1592 #endif |
| 1593 visitor->trace(m_inspectorUserAgentStyleSheet); | 1593 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1594 InspectorBaseAgent::trace(visitor); | 1594 InspectorBaseAgent::trace(visitor); |
| 1595 } | 1595 } |
| 1596 | 1596 |
| 1597 } // namespace blink | 1597 } // namespace blink |
| 1598 | 1598 |
| OLD | NEW |