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

Issue 172593003: DevTools: [CSS] Add CSS.editRangeInStyleSheetText() to the protocol (Closed)

Created:
6 years, 10 months ago by lushnikov
Modified:
6 years, 9 months ago
Reviewers:
apavlov, vsevik, pfeldman
CC:
blink-reviews, caseq+blink_chromium.org, Mikhail, loislo+blink_chromium.org, eustas+blink_chromium.org, alph+blink_chromium.org, yurys+blink_chromium.org, lushnikov+blink_chromium.org, abarth-chromium, vsevik+blink_chromium.org, pfeldman+blink_chromium.org, paulirish+reviews_chromium.org, apavlov+blink_chromium.org, adamk+blink_chromium.org, devtools-reviews_chromium.org, aandrey+blink_chromium.org, Inactive
Visibility:
Public.

Description

DevTools: [CSS] Add CSS.editRangeInStyleSheetText() to the protocol This patch adds method "editRangeInStyleSheetText" into CSS domain of protocol.json. Also this doesn't simplify protocol on its own, usages of methods setPropertyText and setSelectorText will be eventually substituted with the call to this method. BUG=341506

Patch Set 1 #

Total comments: 26

Patch Set 2 : address @apavlov & @pfeldman comments #

Total comments: 4

Patch Set 3 : address comments #

Total comments: 26

Patch Set 4 : address all comments #

Total comments: 2

Patch Set 5 : address vsevik comments #

Total comments: 4

Patch Set 6 : address vsevik comments #2 #

Patch Set 7 : Implement editRange on the InspectorStyleSheet side #

Patch Set 8 : update test expectations with undo/redo test results #

Patch Set 9 : add testcase to verify editing of stylesheets created for style attribute #

Patch Set 10 : EditRange became safeEditRange #

Patch Set 11 : fix certain bugs #

Patch Set 12 : rebaseline #

Patch Set 13 : fix glitch #

Total comments: 13
Unified diffs Side-by-side diffs Delta from patch set Stats (+1132 lines, -53 lines) Patch
M LayoutTests/http/tests/inspector-protocol/inspector-protocol-test.js View 1 2 3 4 5 6 7 8 9 1 chunk +16 lines, -0 lines 0 comments Download
A LayoutTests/inspector-protocol/css/css-edit-range.html View 1 2 3 4 5 6 7 8 9 10 1 chunk +253 lines, -0 lines 1 comment Download
A LayoutTests/inspector-protocol/css/css-edit-range-expected.txt View 1 2 3 4 5 6 7 8 9 10 1 chunk +211 lines, -0 lines 0 comments Download
A LayoutTests/inspector-protocol/css/css-edit-range-inline-attr.html View 1 2 3 4 5 6 7 8 9 1 chunk +89 lines, -0 lines 0 comments Download
A LayoutTests/inspector-protocol/css/css-edit-range-inline-attr-expected.txt View 1 2 3 4 5 6 7 8 9 10 1 chunk +31 lines, -0 lines 0 comments Download
M LayoutTests/inspector-protocol/css/css-get-platform-fonts.html View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -15 lines 0 comments Download
M LayoutTests/inspector-protocol/css/css-protocol-test.js View 1 2 3 4 5 6 7 8 9 10 3 chunks +41 lines, -9 lines 1 comment Download
M LayoutTests/inspector-protocol/css/css-set-inline-styleSheetText.html View 1 2 3 4 5 6 7 8 3 chunks +7 lines, -19 lines 0 comments Download
A LayoutTests/inspector-protocol/css/edit-range-utils.js View 1 2 3 4 5 6 7 8 9 1 chunk +60 lines, -0 lines 3 comments Download
A LayoutTests/inspector-protocol/css/resources/edit-range.css View 1 2 3 4 5 6 7 8 9 1 chunk +18 lines, -0 lines 0 comments Download
M Source/core/css/CSSPropertySourceData.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +1 line, -1 line 1 comment Download
M Source/core/inspector/InspectorCSSAgent.h View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -0 lines 0 comments Download
M Source/core/inspector/InspectorCSSAgent.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +120 lines, -1 line 1 comment Download
M Source/core/inspector/InspectorStyleSheet.h View 1 2 3 4 5 6 7 8 9 6 chunks +15 lines, -0 lines 0 comments Download
M Source/core/inspector/InspectorStyleSheet.cpp View 1 2 3 4 5 6 7 8 9 10 11 7 chunks +244 lines, -7 lines 6 comments Download
M Source/devtools/protocol.json View 1 2 3 4 5 6 7 8 9 10 1 chunk +14 lines, -1 line 0 comments Download
M Source/wtf/text/TextPosition.h View 1 chunk +1 line, -0 lines 0 comments Download
M Source/wtf/text/TextPosition.cpp View 1 chunk +6 lines, -0 lines 0 comments Download

Messages

Total messages: 20 (0 generated)
lushnikov
please take a look
6 years, 10 months ago (2014-02-19 17:01:40 UTC) #1
apavlov
https://codereview.chromium.org/172593003/diff/1/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js File LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js (right): https://codereview.chromium.org/172593003/diff/1/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js#newcode231 LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js:231: InspectorTest.sendCommandOrDie = function(command, properties, callback) { The name does ...
6 years, 10 months ago (2014-02-20 09:58:13 UTC) #2
apavlov
Please also give a descriptive subject of the change, so that Adam Barth can understand ...
6 years, 10 months ago (2014-02-20 10:09:17 UTC) #3
pfeldman
https://codereview.chromium.org/172593003/diff/1/Source/core/inspector/InspectorCSSAgent.cpp File Source/core/inspector/InspectorCSSAgent.cpp (right): https://codereview.chromium.org/172593003/diff/1/Source/core/inspector/InspectorCSSAgent.cpp#newcode841 Source/core/inspector/InspectorCSSAgent.cpp:841: void InspectorCSSAgent::replaceRangeInStyleSheetText(ErrorString* errorString, const String& styleSheetId, const RefPtr<JSONObject>& range, ...
6 years, 10 months ago (2014-02-20 11:29:04 UTC) #4
lushnikov
Please, take another look https://codereview.chromium.org/172593003/diff/1/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js File LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js (right): https://codereview.chromium.org/172593003/diff/1/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js#newcode231 LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js:231: InspectorTest.sendCommandOrDie = function(command, properties, callback) ...
6 years, 10 months ago (2014-02-20 14:17:03 UTC) #5
apavlov
https://codereview.chromium.org/172593003/diff/100001/Source/core/inspector/InspectorStyleSheet.cpp File Source/core/inspector/InspectorStyleSheet.cpp (right): https://codereview.chromium.org/172593003/diff/100001/Source/core/inspector/InspectorStyleSheet.cpp#newcode1560 Source/core/inspector/InspectorStyleSheet.cpp:1560: bool InspectorStyleSheet::lineNumberAndColumnToOffset(int lineNumber, int columnNumber, unsigned* offset) const int ...
6 years, 10 months ago (2014-02-20 14:21:23 UTC) #6
lushnikov
https://codereview.chromium.org/172593003/diff/100001/Source/core/inspector/InspectorStyleSheet.cpp File Source/core/inspector/InspectorStyleSheet.cpp (right): https://codereview.chromium.org/172593003/diff/100001/Source/core/inspector/InspectorStyleSheet.cpp#newcode1560 Source/core/inspector/InspectorStyleSheet.cpp:1560: bool InspectorStyleSheet::lineNumberAndColumnToOffset(int lineNumber, int columnNumber, unsigned* offset) const On ...
6 years, 10 months ago (2014-02-20 14:37:34 UTC) #7
apavlov
https://codereview.chromium.org/172593003/diff/150001/LayoutTests/inspector-protocol/css/css-edit-range.html File LayoutTests/inspector-protocol/css/css-edit-range.html (right): https://codereview.chromium.org/172593003/diff/150001/LayoutTests/inspector-protocol/css/css-edit-range.html#newcode82 LayoutTests/inspector-protocol/css/css-edit-range.html:82: function testOutOfBoundsRangeParametersNoCrash(next) What about the range: - ending on ...
6 years, 10 months ago (2014-02-21 14:37:54 UTC) #8
lushnikov
https://codereview.chromium.org/172593003/diff/150001/Source/devtools/front_end/StylesSidebarPane.js File Source/devtools/front_end/StylesSidebarPane.js (right): https://codereview.chromium.org/172593003/diff/150001/Source/devtools/front_end/StylesSidebarPane.js#newcode183 Source/devtools/front_end/StylesSidebarPane.js:183: _forcedPseudoClasses: function() On 2014/02/21 14:37:55, apavlov wrote: > how ...
6 years, 10 months ago (2014-02-21 14:57:34 UTC) #9
lushnikov
Thanks for another round of comments! Addressed 'em all https://codereview.chromium.org/172593003/diff/150001/LayoutTests/inspector-protocol/css/css-edit-range.html File LayoutTests/inspector-protocol/css/css-edit-range.html (right): https://codereview.chromium.org/172593003/diff/150001/LayoutTests/inspector-protocol/css/css-edit-range.html#newcode82 LayoutTests/inspector-protocol/css/css-edit-range.html:82: ...
6 years, 10 months ago (2014-02-23 16:07:07 UTC) #10
apavlov
Nice! LGTM
6 years, 10 months ago (2014-02-23 17:43:06 UTC) #11
lushnikov
On 2014/02/23 17:43:06, apavlov wrote: > Nice! LGTM Great! Thanks for the review!
6 years, 9 months ago (2014-02-24 08:49:57 UTC) #12
lushnikov
eseidel: Please review changes in wtf/text vsevik: Please review protocol.json changes
6 years, 9 months ago (2014-02-24 08:54:14 UTC) #13
vsevik
https://codereview.chromium.org/172593003/diff/260001/Source/devtools/protocol.json File Source/devtools/protocol.json (right): https://codereview.chromium.org/172593003/diff/260001/Source/devtools/protocol.json#newcode2656 Source/devtools/protocol.json:2656: "description": "Replace stylesheet text range with a new text, ...
6 years, 9 months ago (2014-02-25 10:42:41 UTC) #14
lushnikov
https://codereview.chromium.org/172593003/diff/260001/Source/devtools/protocol.json File Source/devtools/protocol.json (right): https://codereview.chromium.org/172593003/diff/260001/Source/devtools/protocol.json#newcode2656 Source/devtools/protocol.json:2656: "description": "Replace stylesheet text range with a new text, ...
6 years, 9 months ago (2014-02-25 11:05:44 UTC) #15
vsevik
lgtm https://chromiumcodereview.appspot.com/172593003/diff/320001/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js File LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js (right): https://chromiumcodereview.appspot.com/172593003/diff/320001/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js#newcode231 LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js:231: InspectorTest.sendCommandAndBailOnError = function(command, properties, callback) { { on ...
6 years, 9 months ago (2014-02-25 11:20:48 UTC) #16
lushnikov
Nice, thank you for the review https://chromiumcodereview.appspot.com/172593003/diff/320001/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js File LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js (right): https://chromiumcodereview.appspot.com/172593003/diff/320001/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js#newcode231 LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js:231: InspectorTest.sendCommandAndBailOnError = function(command, ...
6 years, 9 months ago (2014-02-25 11:31:59 UTC) #17
lushnikov
Please, take a look. This change implements the "editRange" version of method that does OM ...
6 years, 9 months ago (2014-03-08 14:35:45 UTC) #18
pfeldman
not lgtm. this change adds complexity with no clear long term plan on removing it.
6 years, 9 months ago (2014-03-13 05:43:00 UTC) #19
vsevik
6 years, 9 months ago (2014-03-13 10:44:50 UTC) #20
Publishing my comments to the implementation in case we reuse some of this code.

https://chromiumcodereview.appspot.com/172593003/diff/470001/LayoutTests/insp...
File LayoutTests/inspector-protocol/css/css-edit-range.html (right):

https://chromiumcodereview.appspot.com/172593003/diff/470001/LayoutTests/insp...
LayoutTests/inspector-protocol/css/css-edit-range.html:38: },
InspectorTest.undoAndNext(next));
Can we make a simple InspectorTest.domUndo(callback) and pass
InspectorTest.domUndo.bind(InspectorTest, next) here?

https://chromiumcodereview.appspot.com/172593003/diff/470001/LayoutTests/insp...
File LayoutTests/inspector-protocol/css/css-protocol-test.js (right):

https://chromiumcodereview.appspot.com/172593003/diff/470001/LayoutTests/insp...
LayoutTests/inspector-protocol/css/css-protocol-test.js:81: function
dumpProperties(properties, indent)
We could probably reuse it on dumpRuleMatch

https://chromiumcodereview.appspot.com/172593003/diff/470001/LayoutTests/insp...
File LayoutTests/inspector-protocol/css/edit-range-utils.js (right):

https://chromiumcodereview.appspot.com/172593003/diff/470001/LayoutTests/insp...
LayoutTests/inspector-protocol/css/edit-range-utils.js:1: var
initialize_EditRangeHelpers = function() {
This could be put in css-protocol-test.js

https://chromiumcodereview.appspot.com/172593003/diff/470001/LayoutTests/insp...
LayoutTests/inspector-protocol/css/edit-range-utils.js:34:
InspectorTest.undoAndNext = function(next)
This seems to complicated.

https://chromiumcodereview.appspot.com/172593003/diff/470001/LayoutTests/insp...
LayoutTests/inspector-protocol/css/edit-range-utils.js:43:
InspectorTest.checkProtocolError = function(styleSheetId, options, callback)
InspectorTest.editStyleSheetExpectError

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/css/...
File Source/core/css/CSSPropertySourceData.cpp (right):

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/css/...
Source/core/css/CSSPropertySourceData.cpp:112: unsigned
CSSPropertySourceData::hash() const
Can we replace it with equals?

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
File Source/core/inspector/InspectorCSSAgent.cpp (right):

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
Source/core/inspector/InspectorCSSAgent.cpp:947:
editAction->setExternalEditRangeResult(&editRangeResult);
Wouldn't it be simpler to add an actionResult getter on this action instead?

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
File Source/core/inspector/InspectorStyleSheet.cpp (right):

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
Source/core/inspector/InspectorStyleSheet.cpp:945: static bool
verifyEditLocalizedToRule(const ParsedStyleSheet* originalData, const
ParsedStyleSheet* modifiedData, const unsigned ruleIndex, ExceptionState&
exceptionState)
This method does something different from what its name suggests and this is bad
:)

Let's check text before and after rule matches in both stylesheets.

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
Source/core/inspector/InspectorStyleSheet.cpp:1042: size_t minSize =
std::min(originalSize, modifiedSize);
size_t minSize = originalSize;
So let's remove it.

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
Source/core/inspector/InspectorStyleSheet.cpp:1044: while (leadingCongruent <
minSize) {
Can we use text for this instead?

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
Source/core/inspector/InspectorStyleSheet.cpp:1096: continue;
if (!editRange intersects with rule range)
    continue;
if (!verifyEditLocalizedToRule(m_parsedStyleSheet, editedParsedData.get(), i,
exceptio
      nState))
    return false;

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
Source/core/inspector/InspectorStyleSheet.cpp:1118: return
handleStyleSheetEditScope(m_parsedStyleSheet, editedParsedData.get(),
editRangeResult, exceptionState);
return false;

https://chromiumcodereview.appspot.com/172593003/diff/470001/Source/core/insp...
Source/core/inspector/InspectorStyleSheet.cpp:1885: if (m_styleText.isEmpty()) {
This is not needed anymore.

Powered by Google App Engine
This is Rietveld 408576698