Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/inspector/InspectorDOMAgent.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 class InspectorCSSAgent::SetStyleSheetTextAction : public InspectorCSSAgent::Sty leSheetAction { 312 class InspectorCSSAgent::SetStyleSheetTextAction : public InspectorCSSAgent::Sty leSheetAction {
313 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction); 313 WTF_MAKE_NONCOPYABLE(SetStyleSheetTextAction);
314 public: 314 public:
315 SetStyleSheetTextAction(InspectorStyleSheet* styleSheet, const String& text) 315 SetStyleSheetTextAction(InspectorStyleSheet* styleSheet, const String& text)
316 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText", styleSheet) 316 : InspectorCSSAgent::StyleSheetAction("SetStyleSheetText", styleSheet)
317 , m_text(text) 317 , m_text(text)
318 { 318 {
319 } 319 }
320 320
321 virtual bool perform(ExceptionState& es) 321 virtual bool perform(ExceptionState& exceptionState)
322 { 322 {
323 if (!m_styleSheet->getText(&m_oldText)) 323 if (!m_styleSheet->getText(&m_oldText))
324 return false; 324 return false;
325 return redo(es); 325 return redo(exceptionState);
326 } 326 }
327 327
328 virtual bool undo(ExceptionState& es) 328 virtual bool undo(ExceptionState& exceptionState)
329 { 329 {
330 if (m_styleSheet->setText(m_oldText, es)) { 330 if (m_styleSheet->setText(m_oldText, exceptionState)) {
331 m_styleSheet->reparseStyleSheet(m_oldText); 331 m_styleSheet->reparseStyleSheet(m_oldText);
332 return true; 332 return true;
333 } 333 }
334 return false; 334 return false;
335 } 335 }
336 336
337 virtual bool redo(ExceptionState& es) 337 virtual bool redo(ExceptionState& exceptionState)
338 { 338 {
339 if (m_styleSheet->setText(m_text, es)) { 339 if (m_styleSheet->setText(m_text, exceptionState)) {
340 m_styleSheet->reparseStyleSheet(m_text); 340 m_styleSheet->reparseStyleSheet(m_text);
341 return true; 341 return true;
342 } 342 }
343 return false; 343 return false;
344 } 344 }
345 345
346 virtual String mergeId() 346 virtual String mergeId()
347 { 347 {
348 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8(). data()); 348 return String::format("SetStyleSheetText %s", m_styleSheet->id().utf8(). data());
349 } 349 }
(...skipping 19 matching lines...) Expand all
369 , m_cssId(cssId) 369 , m_cssId(cssId)
370 , m_text(text) 370 , m_text(text)
371 { 371 {
372 } 372 }
373 373
374 virtual String toString() 374 virtual String toString()
375 { 375 {
376 return mergeId() + ": " + m_oldText + " -> " + m_text; 376 return mergeId() + ": " + m_oldText + " -> " + m_text;
377 } 377 }
378 378
379 virtual bool perform(ExceptionState& es) 379 virtual bool perform(ExceptionState& exceptionState)
380 { 380 {
381 return redo(es); 381 return redo(exceptionState);
382 } 382 }
383 383
384 virtual bool undo(ExceptionState& es) 384 virtual bool undo(ExceptionState& exceptionState)
385 { 385 {
386 String placeholder; 386 String placeholder;
387 return m_styleSheet->setStyleText(m_cssId, m_oldText, &placeholder, es); 387 return m_styleSheet->setStyleText(m_cssId, m_oldText, &placeholder, exce ptionState);
388 } 388 }
389 389
390 virtual bool redo(ExceptionState& es) 390 virtual bool redo(ExceptionState& exceptionState)
391 { 391 {
392 return m_styleSheet->setStyleText(m_cssId, m_text, &m_oldText, es); 392 return m_styleSheet->setStyleText(m_cssId, m_text, &m_oldText, exception State);
393 } 393 }
394 394
395 virtual String mergeId() 395 virtual String mergeId()
396 { 396 {
397 return String::format("SetStyleText %s:%u", m_cssId.styleSheetId().utf8( ).data(), m_cssId.ordinal()); 397 return String::format("SetStyleText %s:%u", m_cssId.styleSheetId().utf8( ).data(), m_cssId.ordinal());
398 } 398 }
399 399
400 virtual void merge(PassOwnPtr<Action> action) 400 virtual void merge(PassOwnPtr<Action> action)
401 { 401 {
402 ASSERT(action->mergeId() == mergeId()); 402 ASSERT(action->mergeId() == mergeId());
(...skipping 18 matching lines...) Expand all
421 , m_text(text) 421 , m_text(text)
422 , m_overwrite(overwrite) 422 , m_overwrite(overwrite)
423 { 423 {
424 } 424 }
425 425
426 virtual String toString() 426 virtual String toString()
427 { 427 {
428 return mergeId() + ": " + m_oldText + " -> " + m_text; 428 return mergeId() + ": " + m_oldText + " -> " + m_text;
429 } 429 }
430 430
431 virtual bool perform(ExceptionState& es) 431 virtual bool perform(ExceptionState& exceptionState)
432 { 432 {
433 return redo(es); 433 return redo(exceptionState);
434 } 434 }
435 435
436 virtual bool undo(ExceptionState& es) 436 virtual bool undo(ExceptionState& exceptionState)
437 { 437 {
438 String placeholder; 438 String placeholder;
439 return m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_overwri te ? m_oldText : "", true, &placeholder, es); 439 return m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_overwri te ? m_oldText : "", true, &placeholder, exceptionState);
440 } 440 }
441 441
442 virtual bool redo(ExceptionState& es) 442 virtual bool redo(ExceptionState& exceptionState)
443 { 443 {
444 String oldText; 444 String oldText;
445 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_ text, m_overwrite, &oldText, es); 445 bool result = m_styleSheet->setPropertyText(m_cssId, m_propertyIndex, m_ text, m_overwrite, &oldText, exceptionState);
446 m_oldText = oldText.stripWhiteSpace(); 446 m_oldText = oldText.stripWhiteSpace();
447 // FIXME: remove this once the model handles this case. 447 // FIXME: remove this once the model handles this case.
448 if (!m_oldText.endsWith(';')) 448 if (!m_oldText.endsWith(';'))
449 m_oldText.append(';'); 449 m_oldText.append(';');
450 return result; 450 return result;
451 } 451 }
452 452
453 virtual String mergeId() 453 virtual String mergeId()
454 { 454 {
455 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf 8().data(), m_propertyIndex, m_overwrite ? "true" : "false"); 455 return String::format("SetPropertyText %s:%u:%s", m_styleSheet->id().utf 8().data(), m_propertyIndex, m_overwrite ? "true" : "false");
(...skipping 19 matching lines...) Expand all
475 WTF_MAKE_NONCOPYABLE(TogglePropertyAction); 475 WTF_MAKE_NONCOPYABLE(TogglePropertyAction);
476 public: 476 public:
477 TogglePropertyAction(InspectorStyleSheet* styleSheet, const InspectorCSSId& cssId, unsigned propertyIndex, bool disable) 477 TogglePropertyAction(InspectorStyleSheet* styleSheet, const InspectorCSSId& cssId, unsigned propertyIndex, bool disable)
478 : InspectorCSSAgent::StyleSheetAction("ToggleProperty", styleSheet) 478 : InspectorCSSAgent::StyleSheetAction("ToggleProperty", styleSheet)
479 , m_cssId(cssId) 479 , m_cssId(cssId)
480 , m_propertyIndex(propertyIndex) 480 , m_propertyIndex(propertyIndex)
481 , m_disable(disable) 481 , m_disable(disable)
482 { 482 {
483 } 483 }
484 484
485 virtual bool perform(ExceptionState& es) 485 virtual bool perform(ExceptionState& exceptionState)
486 { 486 {
487 return redo(es); 487 return redo(exceptionState);
488 } 488 }
489 489
490 virtual bool undo(ExceptionState& es) 490 virtual bool undo(ExceptionState& exceptionState)
491 { 491 {
492 return m_styleSheet->toggleProperty(m_cssId, m_propertyIndex, !m_disable , es); 492 return m_styleSheet->toggleProperty(m_cssId, m_propertyIndex, !m_disable , exceptionState);
493 } 493 }
494 494
495 virtual bool redo(ExceptionState& es) 495 virtual bool redo(ExceptionState& exceptionState)
496 { 496 {
497 return m_styleSheet->toggleProperty(m_cssId, m_propertyIndex, m_disable, es); 497 return m_styleSheet->toggleProperty(m_cssId, m_propertyIndex, m_disable, exceptionState);
498 } 498 }
499 499
500 private: 500 private:
501 InspectorCSSId m_cssId; 501 InspectorCSSId m_cssId;
502 unsigned m_propertyIndex; 502 unsigned m_propertyIndex;
503 bool m_disable; 503 bool m_disable;
504 }; 504 };
505 505
506 class InspectorCSSAgent::SetRuleSelectorAction : public InspectorCSSAgent::Style SheetAction { 506 class InspectorCSSAgent::SetRuleSelectorAction : public InspectorCSSAgent::Style SheetAction {
507 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction); 507 WTF_MAKE_NONCOPYABLE(SetRuleSelectorAction);
508 public: 508 public:
509 SetRuleSelectorAction(InspectorStyleSheet* styleSheet, const InspectorCSSId& cssId, const String& selector) 509 SetRuleSelectorAction(InspectorStyleSheet* styleSheet, const InspectorCSSId& cssId, const String& selector)
510 : InspectorCSSAgent::StyleSheetAction("SetRuleSelector", styleSheet) 510 : InspectorCSSAgent::StyleSheetAction("SetRuleSelector", styleSheet)
511 , m_cssId(cssId) 511 , m_cssId(cssId)
512 , m_selector(selector) 512 , m_selector(selector)
513 { 513 {
514 } 514 }
515 515
516 virtual bool perform(ExceptionState& es) 516 virtual bool perform(ExceptionState& exceptionState)
517 { 517 {
518 m_oldSelector = m_styleSheet->ruleSelector(m_cssId, es); 518 m_oldSelector = m_styleSheet->ruleSelector(m_cssId, exceptionState);
519 if (es.hadException()) 519 if (exceptionState.hadException())
520 return false; 520 return false;
521 return redo(es); 521 return redo(exceptionState);
522 } 522 }
523 523
524 virtual bool undo(ExceptionState& es) 524 virtual bool undo(ExceptionState& exceptionState)
525 { 525 {
526 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, es); 526 return m_styleSheet->setRuleSelector(m_cssId, m_oldSelector, exceptionSt ate);
527 } 527 }
528 528
529 virtual bool redo(ExceptionState& es) 529 virtual bool redo(ExceptionState& exceptionState)
530 { 530 {
531 return m_styleSheet->setRuleSelector(m_cssId, m_selector, es); 531 return m_styleSheet->setRuleSelector(m_cssId, m_selector, exceptionState );
532 } 532 }
533 533
534 private: 534 private:
535 InspectorCSSId m_cssId; 535 InspectorCSSId m_cssId;
536 String m_selector; 536 String m_selector;
537 String m_oldSelector; 537 String m_oldSelector;
538 }; 538 };
539 539
540 class InspectorCSSAgent::AddRuleAction : public InspectorCSSAgent::StyleSheetAct ion { 540 class InspectorCSSAgent::AddRuleAction : public InspectorCSSAgent::StyleSheetAct ion {
541 WTF_MAKE_NONCOPYABLE(AddRuleAction); 541 WTF_MAKE_NONCOPYABLE(AddRuleAction);
542 public: 542 public:
543 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector) 543 AddRuleAction(InspectorStyleSheet* styleSheet, const String& selector)
544 : InspectorCSSAgent::StyleSheetAction("AddRule", styleSheet) 544 : InspectorCSSAgent::StyleSheetAction("AddRule", styleSheet)
545 , m_selector(selector) 545 , m_selector(selector)
546 { 546 {
547 } 547 }
548 548
549 virtual bool perform(ExceptionState& es) 549 virtual bool perform(ExceptionState& exceptionState)
550 { 550 {
551 return redo(es); 551 return redo(exceptionState);
552 } 552 }
553 553
554 virtual bool undo(ExceptionState& es) 554 virtual bool undo(ExceptionState& exceptionState)
555 { 555 {
556 return m_styleSheet->deleteRule(m_newId, es); 556 return m_styleSheet->deleteRule(m_newId, exceptionState);
557 } 557 }
558 558
559 virtual bool redo(ExceptionState& es) 559 virtual bool redo(ExceptionState& exceptionState)
560 { 560 {
561 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, es); 561 CSSStyleRule* cssStyleRule = m_styleSheet->addRule(m_selector, exception State);
562 if (es.hadException()) 562 if (exceptionState.hadException())
563 return false; 563 return false;
564 m_newId = m_styleSheet->ruleId(cssStyleRule); 564 m_newId = m_styleSheet->ruleId(cssStyleRule);
565 return true; 565 return true;
566 } 566 }
567 567
568 InspectorCSSId newRuleId() { return m_newId; } 568 InspectorCSSId newRuleId() { return m_newId; }
569 569
570 private: 570 private:
571 InspectorCSSId m_newId; 571 InspectorCSSId m_newId;
572 String m_selector; 572 String m_selector;
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 1125
1126 inspectorStyleSheet->getText(result); 1126 inspectorStyleSheet->getText(result);
1127 } 1127 }
1128 1128
1129 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String & styleSheetId, const String& text) 1129 void InspectorCSSAgent::setStyleSheetText(ErrorString* errorString, const String & styleSheetId, const String& text)
1130 { 1130 {
1131 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , styleSheetId); 1131 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , styleSheetId);
1132 if (!inspectorStyleSheet) 1132 if (!inspectorStyleSheet)
1133 return; 1133 return;
1134 1134
1135 TrackExceptionState es; 1135 TrackExceptionState exceptionState;
1136 m_domAgent->history()->perform(adoptPtr(new SetStyleSheetTextAction(inspecto rStyleSheet, text)), es); 1136 m_domAgent->history()->perform(adoptPtr(new SetStyleSheetTextAction(inspecto rStyleSheet, text)), exceptionState);
1137 *errorString = InspectorDOMAgent::toErrorString(es); 1137 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
1138 } 1138 }
1139 1139
1140 void InspectorCSSAgent::setStyleText(ErrorString* errorString, const RefPtr<JSON Object>& fullStyleId, const String& text, RefPtr<TypeBuilder::CSS::CSSStyle>& re sult) 1140 void InspectorCSSAgent::setStyleText(ErrorString* errorString, const RefPtr<JSON Object>& fullStyleId, const String& text, RefPtr<TypeBuilder::CSS::CSSStyle>& re sult)
1141 { 1141 {
1142 InspectorCSSId compoundId(fullStyleId); 1142 InspectorCSSId compoundId(fullStyleId);
1143 ASSERT(!compoundId.isEmpty()); 1143 ASSERT(!compoundId.isEmpty());
1144 1144
1145 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId()); 1145 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId());
1146 if (!inspectorStyleSheet) 1146 if (!inspectorStyleSheet)
1147 return; 1147 return;
1148 1148
1149 TrackExceptionState es; 1149 TrackExceptionState exceptionState;
1150 m_domAgent->history()->perform(adoptPtr(new SetStyleTextAction(inspectorStyl eSheet, compoundId, text)), es); 1150 m_domAgent->history()->perform(adoptPtr(new SetStyleTextAction(inspectorStyl eSheet, compoundId, text)), exceptionState);
1151 if (!es.hadException()) 1151 if (!exceptionState.hadException())
1152 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s tyleForId(compoundId)); 1152 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s tyleForId(compoundId));
1153 *errorString = InspectorDOMAgent::toErrorString(es); 1153 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
1154 } 1154 }
1155 1155
1156 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result) 1156 void InspectorCSSAgent::setPropertyText(ErrorString* errorString, const RefPtr<J SONObject>& fullStyleId, int propertyIndex, const String& text, bool overwrite, RefPtr<TypeBuilder::CSS::CSSStyle>& result)
1157 { 1157 {
1158 InspectorCSSId compoundId(fullStyleId); 1158 InspectorCSSId compoundId(fullStyleId);
1159 ASSERT(!compoundId.isEmpty()); 1159 ASSERT(!compoundId.isEmpty());
1160 1160
1161 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId()); 1161 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId());
1162 if (!inspectorStyleSheet) 1162 if (!inspectorStyleSheet)
1163 return; 1163 return;
1164 1164
1165 TrackExceptionState es; 1165 TrackExceptionState exceptionState;
1166 bool success = m_domAgent->history()->perform(adoptPtr(new SetPropertyTextAc tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), es); 1166 bool success = m_domAgent->history()->perform(adoptPtr(new SetPropertyTextAc tion(inspectorStyleSheet, compoundId, propertyIndex, text, overwrite)), exceptio nState);
1167 if (success) 1167 if (success)
1168 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s tyleForId(compoundId)); 1168 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s tyleForId(compoundId));
1169 *errorString = InspectorDOMAgent::toErrorString(es); 1169 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
1170 } 1170 }
1171 1171
1172 void InspectorCSSAgent::toggleProperty(ErrorString* errorString, const RefPtr<JS ONObject>& fullStyleId, int propertyIndex, bool disable, RefPtr<TypeBuilder::CSS ::CSSStyle>& result) 1172 void InspectorCSSAgent::toggleProperty(ErrorString* errorString, const RefPtr<JS ONObject>& fullStyleId, int propertyIndex, bool disable, RefPtr<TypeBuilder::CSS ::CSSStyle>& result)
1173 { 1173 {
1174 InspectorCSSId compoundId(fullStyleId); 1174 InspectorCSSId compoundId(fullStyleId);
1175 ASSERT(!compoundId.isEmpty()); 1175 ASSERT(!compoundId.isEmpty());
1176 1176
1177 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId()); 1177 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId());
1178 if (!inspectorStyleSheet) 1178 if (!inspectorStyleSheet)
1179 return; 1179 return;
1180 1180
1181 TrackExceptionState es; 1181 TrackExceptionState exceptionState;
1182 bool success = m_domAgent->history()->perform(adoptPtr(new TogglePropertyAct ion(inspectorStyleSheet, compoundId, propertyIndex, disable)), es); 1182 bool success = m_domAgent->history()->perform(adoptPtr(new TogglePropertyAct ion(inspectorStyleSheet, compoundId, propertyIndex, disable)), exceptionState);
1183 if (success) 1183 if (success)
1184 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s tyleForId(compoundId)); 1184 result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->s tyleForId(compoundId));
1185 *errorString = InspectorDOMAgent::toErrorString(es); 1185 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
1186 } 1186 }
1187 1187
1188 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<J SONObject>& fullRuleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule >& result) 1188 void InspectorCSSAgent::setRuleSelector(ErrorString* errorString, const RefPtr<J SONObject>& fullRuleId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule >& result)
1189 { 1189 {
1190 InspectorCSSId compoundId(fullRuleId); 1190 InspectorCSSId compoundId(fullRuleId);
1191 ASSERT(!compoundId.isEmpty()); 1191 ASSERT(!compoundId.isEmpty());
1192 1192
1193 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId()); 1193 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , compoundId.styleSheetId());
1194 if (!inspectorStyleSheet) 1194 if (!inspectorStyleSheet)
1195 return; 1195 return;
1196 1196
1197 TrackExceptionState es; 1197 TrackExceptionState exceptionState;
1198 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc tion(inspectorStyleSheet, compoundId, selector)), es); 1198 bool success = m_domAgent->history()->perform(adoptPtr(new SetRuleSelectorAc tion(inspectorStyleSheet, compoundId, selector)), exceptionState);
1199 1199
1200 if (success) { 1200 if (success) {
1201 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId); 1201 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(compoundId);
1202 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha in(rule)); 1202 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListCha in(rule));
1203 } 1203 }
1204 *errorString = InspectorDOMAgent::toErrorString(es); 1204 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
1205 } 1205 }
1206 1206
1207 void InspectorCSSAgent::addRule(ErrorString* errorString, const int contextNodeI d, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) 1207 void InspectorCSSAgent::addRule(ErrorString* errorString, const int contextNodeI d, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result)
1208 { 1208 {
1209 Node* node = m_domAgent->assertNode(errorString, contextNodeId); 1209 Node* node = m_domAgent->assertNode(errorString, contextNodeId);
1210 if (!node) 1210 if (!node)
1211 return; 1211 return;
1212 1212
1213 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(&node->doc ument(), true); 1213 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(&node->doc ument(), true);
1214 if (!inspectorStyleSheet) { 1214 if (!inspectorStyleSheet) {
1215 *errorString = "No target stylesheet found"; 1215 *errorString = "No target stylesheet found";
1216 return; 1216 return;
1217 } 1217 }
1218 1218
1219 TrackExceptionState es; 1219 TrackExceptionState exceptionState;
1220 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee t, selector)); 1220 OwnPtr<AddRuleAction> action = adoptPtr(new AddRuleAction(inspectorStyleShee t, selector));
1221 AddRuleAction* rawAction = action.get(); 1221 AddRuleAction* rawAction = action.get();
1222 bool success = m_domAgent->history()->perform(action.release(), es); 1222 bool success = m_domAgent->history()->perform(action.release(), exceptionSta te);
1223 if (!success) { 1223 if (!success) {
1224 *errorString = InspectorDOMAgent::toErrorString(es); 1224 *errorString = InspectorDOMAgent::toErrorString(exceptionState);
1225 return; 1225 return;
1226 } 1226 }
1227 1227
1228 InspectorCSSId ruleId = rawAction->newRuleId(); 1228 InspectorCSSId ruleId = rawAction->newRuleId();
1229 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId); 1229 CSSStyleRule* rule = inspectorStyleSheet->ruleForId(ruleId);
1230 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r ule)); 1230 result = inspectorStyleSheet->buildObjectForRule(rule, buildMediaListChain(r ule));
1231 } 1231 }
1232 1232
1233 void InspectorCSSAgent::getSupportedCSSProperties(ErrorString*, RefPtr<TypeBuild er::Array<TypeBuilder::CSS::CSSPropertyInfo> >& cssProperties) 1233 void InspectorCSSAgent::getSupportedCSSProperties(ErrorString*, RefPtr<TypeBuild er::Array<TypeBuilder::CSS::CSSPropertyInfo> >& cssProperties)
1234 { 1234 {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 return 0; 1495 return 0;
1496 } 1496 }
1497 1497
1498 if (!document->isHTMLDocument() && !document->isSVGDocument()) 1498 if (!document->isHTMLDocument() && !document->isSVGDocument())
1499 return 0; 1499 return 0;
1500 1500
1501 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToInspectorStyle Sheet.get(document); 1501 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_documentToInspectorStyle Sheet.get(document);
1502 if (inspectorStyleSheet || !createIfAbsent) 1502 if (inspectorStyleSheet || !createIfAbsent)
1503 return inspectorStyleSheet.get(); 1503 return inspectorStyleSheet.get();
1504 1504
1505 TrackExceptionState es; 1505 TrackExceptionState exceptionState;
1506 RefPtr<Element> styleElement = document->createElement("style", es); 1506 RefPtr<Element> styleElement = document->createElement("style", exceptionSta te);
1507 if (!es.hadException()) 1507 if (!exceptionState.hadException())
1508 styleElement->setAttribute("type", "text/css", es); 1508 styleElement->setAttribute("type", "text/css", exceptionState);
1509 if (!es.hadException()) { 1509 if (!exceptionState.hadException()) {
1510 ContainerNode* targetNode; 1510 ContainerNode* targetNode;
1511 // HEAD is absent in ImageDocuments, for example. 1511 // HEAD is absent in ImageDocuments, for example.
1512 if (document->head()) 1512 if (document->head())
1513 targetNode = document->head(); 1513 targetNode = document->head();
1514 else if (document->body()) 1514 else if (document->body())
1515 targetNode = document->body(); 1515 targetNode = document->body();
1516 else 1516 else
1517 return 0; 1517 return 0;
1518 1518
1519 InlineStyleOverrideScope overrideScope(document); 1519 InlineStyleOverrideScope overrideScope(document);
1520 m_creatingViaInspectorStyleSheet = true; 1520 m_creatingViaInspectorStyleSheet = true;
1521 targetNode->appendChild(styleElement, es); 1521 targetNode->appendChild(styleElement, exceptionState);
1522 // At this point the added stylesheet will get bound through the updateA ctiveStyleSheets() invocation. 1522 // At this point the added stylesheet will get bound through the updateA ctiveStyleSheets() invocation.
1523 // We just need to pick the respective InspectorStyleSheet from m_docume ntToInspectorStyleSheet. 1523 // We just need to pick the respective InspectorStyleSheet from m_docume ntToInspectorStyleSheet.
1524 m_creatingViaInspectorStyleSheet = false; 1524 m_creatingViaInspectorStyleSheet = false;
1525 } 1525 }
1526 if (es.hadException()) 1526 if (exceptionState.hadException())
1527 return 0; 1527 return 0;
1528 1528
1529 return m_documentToInspectorStyleSheet.get(document); 1529 return m_documentToInspectorStyleSheet.get(document);
1530 } 1530 }
1531 1531
1532 InspectorStyleSheet* InspectorCSSAgent::assertStyleSheetForId(ErrorString* error String, const String& styleSheetId) 1532 InspectorStyleSheet* InspectorCSSAgent::assertStyleSheetForId(ErrorString* error String, const String& styleSheetId)
1533 { 1533 {
1534 IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.find(styleS heetId); 1534 IdToInspectorStyleSheet::iterator it = m_idToInspectorStyleSheet.find(styleS heetId);
1535 if (it == m_idToInspectorStyleSheet.end()) { 1535 if (it == m_idToInspectorStyleSheet.end()) {
1536 *errorString = "No style sheet with given id found"; 1536 *errorString = "No style sheet with given id found";
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 documentsToChange.add(element->ownerDocument()); 1773 documentsToChange.add(element->ownerDocument());
1774 } 1774 }
1775 1775
1776 m_nodeIdToForcedPseudoState.clear(); 1776 m_nodeIdToForcedPseudoState.clear();
1777 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1777 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1778 (*it)->setNeedsStyleRecalc(); 1778 (*it)->setNeedsStyleRecalc();
1779 } 1779 }
1780 1780
1781 } // namespace WebCore 1781 } // namespace WebCore
1782 1782
OLDNEW
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/inspector/InspectorDOMAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698