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

Unified Diff: Source/core/inspector/InspectorStyleSheet.cpp

Issue 172593003: DevTools: [CSS] Add CSS.editRangeInStyleSheetText() to the protocol (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address vsevik comments Created 6 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InspectorStyleSheet.cpp
diff --git a/Source/core/inspector/InspectorStyleSheet.cpp b/Source/core/inspector/InspectorStyleSheet.cpp
index 7613072d65c6d2ac363843dbf8649e4313da0040..e94125add219e5852e8a88ffddd951cd17ba14d6 100644
--- a/Source/core/inspector/InspectorStyleSheet.cpp
+++ b/Source/core/inspector/InspectorStyleSheet.cpp
@@ -1557,6 +1557,19 @@ InspectorCSSId InspectorStyleSheet::ruleId(CSSStyleRule* rule) const
return ruleOrStyleId(rule->style());
}
+bool InspectorStyleSheet::lineNumberAndColumnToOffset(unsigned lineNumber, unsigned columnNumber, unsigned* offset) const
+{
+ OwnPtr<Vector<unsigned> > endings = lineEndings();
+ if (lineNumber >= endings->size())
+ return false;
+ unsigned charactersInLine = lineNumber > 0 ? endings->at(lineNumber) - endings->at(lineNumber - 1) - 1 : endings->at(0) - 1;
+ if (columnNumber > charactersInLine)
+ return false;
+ TextPosition position(OrdinalNumber::fromZeroBasedInt(lineNumber), OrdinalNumber::fromZeroBasedInt(columnNumber));
+ *offset = position.toOffsetPosition(*endings).zeroBasedInt();
+ return true;
+}
+
void InspectorStyleSheet::revalidateStyle(CSSStyleDeclaration* pageStyle)
{
if (m_isRevalidating)

Powered by Google App Engine
This is Rietveld 408576698